Get meta tag content property with BeautifulSoup and Python

后端 未结 4 1012
遇见更好的自我
遇见更好的自我 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:56

    try this :

    soup = BeautifulSoup(webpage)
    for tag in soup.find_all("meta"):
        if tag.get("property", None) == "og:title":
            print tag.get("content", None)
        elif tag.get("property", None) == "og:url":
            print tag.get("content", None)
    

提交回复
热议问题