我有以下代码:
def downloadData(queryString):
with urllib.request.urlopen(queryString) as url:
encoding = url.headers.get_content_charset()
result = url.read().decode(encoding)
return result
但是对于返回 https 文档的 google,我收到错误:
urllib.error.HTTPError: HTTP Error 403: Forbidden
这是查询字符串:
https://www.google.com/search?q=Dow+Jones+Industrial+Average+Quote+with+volume
我需要如何更改它才能处理 https?谢谢!
最佳答案
关于Python使用urllib读取google搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21680558/