2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Google App EngineでRequestsで取得したHTMLが文字化けするときに確認すること

Posted at

現象

Google App Engine(Python)のRequestsで取ってきたHTMLが文字化け。
ローカルのターミナル(GAEでない)では動いてるのに……。
検索して出てきた
Requestsのマニュアルにあるエンコーディングを変更してもだめ。
contetnsやjsonなど他の取得方法を試してもだめ、
とかなり詰まったので、解決した方法を書いておきます。

まず確認すべきこと

使っているRequestsのバージョンがGAEでサポートされてるのか、ということです。

Google App Engineのライブラリ追加方法に、
pipでインストールするように書いてありますが、そうすると最新バージョンがインストールされます。

ですが、最新版はGAEではサポートされていないようで
下記の回答を元に2.3バージョンをインストールしたら解決しました。

Requestsに限らずバージョンの明記がないライブラリは注意が必要と思います。

参考

Can Python Requests library be used on Google App Engine?

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?