Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there any way to set page encoding manualy #72

Open
ghostku opened this issue Jan 10, 2017 · 0 comments
Open

Is there any way to set page encoding manualy #72

ghostku opened this issue Jan 10, 2017 · 0 comments

Comments

@ghostku
Copy link

ghostku commented Jan 10, 2017

Sometimes robobrwser get wrong encoding for my page. I know that BeautifulSoup supports manual encoding definition can I set up encoding manually and passed it to BeautifullSoup? In my case it founds windows-1252 instead of UTF-8

And if I use just BeautifullSoup with requests - it works fine

>>> from bs4 import BeautifulSoup
>>> from robobrowser import RoboBrowser
>>> import requests
>>> url = 'http://10x10.com.ua/televizor-bravis-led-32d3000-smart-t2-black-v-dnepropetrovske.html'
>>> rb = RoboBrowser(parser='lxml')
>>> rb.open(url)
>>> rb.select('.product-name h1').pop()
<h1>\xd1\u201a\xd0\xb5\xd0\xbb\xd0\xb5\xd0\xb2\xd0\xb8\xd0·\xd0\xbe\xd1\u20ac Bravis LED-32D3000 Smart +T2 black \xd0\xb2 \xd0\u201d\xd0\xbd\xd0\xb5\xd0\xbf\xd1\u20ac\xd0\xbe\xd0\xbf\xd0\xb5\xd1\u201a\xd1\u20ac\xd0\xbe\xd0\xb2\xd1\x81\xd0\xba\xd0\xb5</h1>
>>> bs = BeautifulSoup(requests.get(url).text, 'lxml')
>>> bs.select('.product-name h1').pop()
<h1>телевизор Bravis LED-32D3000 Smart +T2 black в Днепропетровске</h1>
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant