requests笔记2---添加头部信息

版权声明: https://blog.csdn.net/qq_27469815/article/details/82780534

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()
    print(r.text[:1000])
except:
    print('爬取失败')

猜你喜欢

转载自blog.csdn.net/qq_27469815/article/details/82780534