psf / requests

A simple, yet elegant, HTTP library.
https://requests.readthedocs.io/en/latest/
Apache License 2.0
52.19k stars 9.33k forks source link

Request can't get berkshirehathaway letters.html correctly #6761

Closed karlzheng closed 4 months ago

karlzheng commented 4 months ago

Hi team, I use request to get the content of 'https://www.berkshirehathaway.com/letters/letters.html', but it always can't be decoded as text correctly. Could you help to point out the error of following code? Thanks! ` BRK_letters = "https://www.berkshirehathaway.com/letters/"

headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.64 Safari/537.11'
}            

response = requests.get(f"{self.BRK_letters}letters.html", headers=self.headers)

response.raise_for_status()  # Raise error for bad status codes

`

github-actions[bot] commented 4 months ago

As described in the template, we won't be able to answer questions on this issue tracker. Please use Stack Overflow