Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我是 python 新手,并试图使用 requests 库从 IMDb 获取一些信息。我的代码以我的母语捕获所有数据(例如,电影标题),但我想用英语获取它们。我如何更改请求中的接受语言来做到这一点?
您需要做的就是定义自己的标题:
import requests url = "http://www.imdb.com/title/tt0089218/" headers = {"Accept-Language": "en-US,en;q=0.5"} r = requests.get(url, headers=headers)
您也可以添加您想要修改的任何其他标题。