相关疑难解决方法(0)

使用Python中的Requests库发送"User-agent"

我想在"User-agent"使用Python请求请求网页时发送一个值.我不确定是否可以将其作为标题的一部分发送,如下面的代码所示:

debug = {'verbose': sys.stderr}
user_agent = {'User-agent': 'Mozilla/5.0'}
response  = requests.get(url, headers = user_agent, config=debug)
Run Code Online (Sandbox Code Playgroud)

调试信息未显示请求期间发送的标头.

在标题中发送此信息是否可以接受?如果没有,我该如何发送?

python web-crawler python-requests

196
推荐指数
3
解决办法
20万
查看次数

标签 统计

python ×1

python-requests ×1

web-crawler ×1