问题
I'm new to python and trying to get some infos from IMDb using requests library. My code is capturing all data (e.g., movie titles) in my native language, but i would like to get them in english. How can i change the accept-language in requests to do that?
回答1:
All you need to do is define your own headers:
import requests
url = "http://www.imdb.com/title/tt0089218/"
headers = {"Accept-Language": "en-US,en;q=0.5"}
r = requests.get(url, headers=headers)
You can add whatever other headers you'd like to modify as well.
来源:https://stackoverflow.com/questions/30561260/python-change-accept-language-using-requests