Python change Accept-Language using requests

后端 未结 1 1518
孤城傲影
孤城傲影 2020-12-16 01:24

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

相关标签:
1条回答
  • 2020-12-16 02:00

    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.

    0 讨论(0)
提交回复
热议问题