Get meta tag content property with BeautifulSoup and Python

后端 未结 4 1016
遇见更好的自我
遇见更好的自我 2021-01-30 16:43

I am trying to use python and beautiful soup to extract the content part of the tags below:


&l         


        
4条回答
  •  温柔的废话
    2021-01-30 16:50

    You could grab the content inside the meta tag with gazpacho:

    from gazpacho import Soup
    
    html = """\
    
    
    """
    
    soup = Soup(html)
    soup.find("meta", {"property": "og:title"}).attrs['content']
    

    Which would output:

    'Super Fun Event 1'
    

提交回复
热议问题