requestsライブラリを使おうとすると以下のエラーが出てしまいます。(編集後)
このサイト(https://review-of-my-life.blogspot.com/)のHTMLを取得したい。
発生している問題・エラーメッセージ
Traceback (most recent call last): File "/Users/??????????/Documents/0902-3.py", line 3, in <module> print(response.text) UnicodeEncodeError: 'UCS-2' codec can't encode characters in position 63417-63417: Non-BMP character not supported in Tk
該当のソースコード
Python3
1import requests 2response = requests.get("https://review-of-my-life.blogspot.com/") 3print(response.text) 4
先ほどあった上記の質問に対しての解決策を試してみたところ。。。
絵文字などのUnicodeのBMP外の文字がphotosに含まれていると提示エラーが発生します。
BMP外の文字をBMP内の文字に置換することでprintできるようになります。
import requests x = requests.get("https://review-of-my-life.blogspot.com/") import sys non_bmp_map = dict.fromkeys(range(0x10000, sys.maxunicode + 1), 0x003f) print(x.translate(non_bmp_map))
新たなエラーAttributeError: 'Response' object has no attribute 'translate'
Traceback (most recent call last): File "/Users/?????????/Documents/0902-3.py", line 6, in <module> print(x.translate(non_bmp_map)) AttributeError: 'Response' object has no attribute 'translate'
試した事
ファイル名とディレクトリ名がかぶるとエラー
この記事をみてみましたがよくわかりません。。。
最初の問題が解決したのであれば、こちらをクローズして、別に質問を上げることをオススメいたします。
回答1件