regex pattern in python for parsing HTML title tags

后端 未结 4 1462
野性不改
野性不改 2020-12-05 20:09

I am learning to use both the re module and the urllib module in python and attempting to write a simple web scraper. Here\'s the code I\'ve writte

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-05 20:39

    It is recommended that you use Beautiful Soup or any other parser to parse HTML, but if you badly want regex the following piece of code would do the job.

    The regex code:

    (.+?)
    

    How it works:

    Produces:

    ['Google']
    ['Welcome to Facebook - Log In, Sign Up or Learn More']
    ['reddit: the front page of the internet']
    

提交回复
热议问题