How to get page title in requests

后端 未结 5 1629
伪装坚强ぢ
伪装坚强ぢ 2020-12-28 22:53

What would be the simplest way to get the title of a page in Requests?

r = requests.get(\'http://www.imdb.com/title/tt0108778/\')
# ? r.title
Friends (TV Ser         


        
5条回答
  •  梦谈多话
    2020-12-28 23:07

    Pythonic HTML Parsing for Humans.

    from requests_html import HTMLSession
    
    print(HTMLSession().get('http://www.imdb.com/title/tt0108778/').html.find('title', first=True).text)
    

提交回复
热议问题