使用Python(BeautifulSoup 4)的Web刮板不';行不通

使用Python(BeautifulSoup 4)的Web刮板不';行不通,python,web-scraping,beautifulsoup,Python,Web Scraping,Beautifulsoup,问题是我不知道怎么做。我正试图打印一个类。第一个文本,它打印整个HTML。如何使用BeatifulSoup 4打印它 import requests from bs4 import BeautifulSoup html = requests.get("http://lifehacker.com/this-video-explains-how-to-survive-a-free-falling-eleva-1738366697").text soup = BeautifulSoup(html)

问题是我不知道怎么做。我正试图打印一个类。第一个文本,它打印整个HTML。如何使用BeatifulSoup 4打印它

import requests
from bs4 import BeautifulSoup

html = requests.get("http://lifehacker.com/this-video-explains-how-to-survive-a-free-falling-eleva-1738366697").text
soup = BeautifulSoup(html)
p = soup.p
meow = soup.find(p['class'] == "first-text")
if meow:
    print(meow)
else:
    print(404)

您正在分析find函数中的逻辑表达式,调用应该如下所示

meow = soup.find('p', class="first-text")
一般来说,您应该在文档中查找这些信息,您可以找到一组很好的示例以及如何使用它的说明