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

render()时utf-8' codec can't encode character '\ud83d #327

Open
hanpurenlirenli opened this issue Aug 31, 2019 · 2 comments
Open

render()时utf-8' codec can't encode character '\ud83d #327

hanpurenlirenli opened this issue Aug 31, 2019 · 2 comments

Comments

@hanpurenlirenli
Copy link

UnicodeEncodeError: 'utf-8' codec can't encode character '\ud83d' in position 12759: surrogates not allowed

这个怎么解决呢,哪里可以加错误忽略

@chuanweihu
Copy link

try:

s = requests_html.HTMLSession()
r = s.get('https://app.testudo.umd.edu/soc/201801/sections?courseIds=DANC229')
r.html.encoding = r.encoding
r.html.render()

refer to
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xce in position 89: invalid continuation byte #91

@omnibug
Copy link

omnibug commented Mar 12, 2021

I found a similar error, but the encoding trick did not work.

import requests_html
s = requests_html.HTMLSession()
r = s.get('https://towardsdatascience.com/adversarial-examples-rethinking-the-definition-298504bc73ad')
r.html.encoding = r.encoding
r.html.render()

[I:pyppeteer.launcher] Browser listening on: ws://127.0.0.1:46965/devtools/browser/d9bafa1c-6771-405b-b6fa-dc1ea00069c1
Traceback (most recent call last):
File "", line 1, in
File "C:\Python38\lib\site-packages\requests_html.py", line 607, in render
html = HTML(url=self.url, html=content.encode(DEFAULT_ENCODING), default_encoding=DEFAULT_ENCODING)
UnicodeEncodeError: 'utf-8' codec can't encode character '\ud835' in position 48847: surrogates not allowed

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

3 participants