Requests library of Python Reptile - Amazon product page crawling

Since this is a browser to access the reptile caused by Amazon denied access. So take user-agent was changed to a standard browser Mozilla / 5.0

import requests

url="https://www.amazon.cn/gp/product/B01M8L5Z3Y"
try:
    kv={'user-agent':'Mozilla/5.0'}
    r=requests.get(url,headers=kv)
    r.raise_for_status()
    r.encoding=r.apparent_encoding
    print(r.text[1000:2000])
except:
    print("爬取失败")
Released seven original articles · won praise 0 · Views 19

Guess you like

Origin blog.csdn.net/qq_44838702/article/details/104984158
Recommended