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

后端 未结 11 1782
南笙
南笙 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:48

    Using regular expressions

    import re
    match = re.search('(.*?)', raw_html)
    title = match.group(1) if match else 'No title'
    

提交回复
热议问题