Skip to content
This repository was archived by the owner on Apr 27, 2025. It is now read-only.
This repository was archived by the owner on Apr 27, 2025. It is now read-only.

Wrong encoding cp1252 #5

@ivan-saorin

Description

@ivan-saorin

Trying to run a query in italian that call a websearch the result always returns the following error:
'```python
import requests
url = "https://www.google.com/search"
params = {"q": "farmacie di turno Genova"}
response = requests.get(url, params=params)
print(response.encoding)
response.encoding = 'utf-8'
print(response.text)

Let's run the code!
</hidden>

○ (07:03 PM 13/10/2024) computer



utf-8 Traceback (most recent call last): File "", line 7, in  File "C:\Program
Files\WindowsApps\PythonSoftwareFoundation.Python.3.11_3.11.2544.0_x64__qbz5n2kfra8p0\Lib\encodings\cp1252.py", line 19, in encode return
codecs.charmap_encode(input,self.errors,encoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeEncodeError: 'charmap' codec can't
encode character '\u0259' in position 20975: character maps to'

The reson seems to rely to the fact that the response is alsways expected as utf-8 while sites could have their own page encoding.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions