0
谷歌的搜索結果,我有以下代碼:Python的讀取與urllib的
def downloadData(queryString):
with urllib.request.urlopen(queryString) as url:
encoding = url.headers.get_content_charset()
result = url.read().decode(encoding)
return result
然而,對於谷歌,它返回HTTPS文件,我得到一個錯誤:
urllib.error.HTTPError: HTTP Error 403: Forbidden
下面是查詢字符串:
https://www.google.com/search?q=Dow+Jones+Industrial+Average+Quote+with+volume
我該如何改變它以處理https?謝謝!
可能會幫助,如果你提供'queryString'你正在使用。 – lanzz
在附註中,您可能需要查看'requests'模塊。它使用起來更容易。 –