Frage

I have the following code:

def downloadData(queryString):
    with urllib.request.urlopen(queryString) as url:
        encoding = url.headers.get_content_charset()
        result = url.read().decode(encoding)
    return result

However for google, which returns https documents, I get an error:

urllib.error.HTTPError: HTTP Error 403: Forbidden

Here is the query string:

https://www.google.com/search?q=Dow+Jones+Industrial+Average+Quote+with+volume

How would I need to change it to process https? Thank you!

War es hilfreich?
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top