How can I retrieve the page title of a webpage using Python?

后端 未结 11 1780
南笙
南笙 2020-12-07 08:55

How can I retrieve the page title of a webpage (title html tag) using Python?

11条回答
  •  星月不相逢
    2020-12-07 09:46

    The mechanize Browser object has a title() method. So the code from this post can be rewritten as:

    from mechanize import Browser
    br = Browser()
    br.open("http://www.google.com/")
    print br.title()
    

提交回复
热议问题