【发布时间】:2018-10-28 19:19:06
【问题描述】:
我正在尝试为我的 urllib 请求设置用户代理:
opener = urllib.request.build_opener(
urllib.request.HTTPCookieProcessor(cj),
urllib.request.HTTPRedirectHandler(),
urllib.request.ProxyHandler({'http': proxy})
)
最后:
response3 = opener.open("https://www.google.com:443/search?q=test", timeout=timeout_value).read().decode("utf-8")
将用户代理标头设置为的最佳方法是什么
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36
【问题讨论】:
标签: python python-3.x python-requests urllib