【发布时间】:2016-12-20 14:16:55
【问题描述】:
我对网络抓取非常陌生。我阅读了 BeautifulSoup 并尝试使用它。但我无法提取具有给定类名“company-desc-and-sort-container”的文本。我什至无法从 html 页面中提取标题。这是我尝试过的代码:
from BeautifulSoup import BeautifulSoup
import requests
url= 'http://fortune.com/best-companies/'
r = requests.get(url)
soup = BeautifulSoup(r.text)
#print soup.prettify()[0:1000]
print soup.find_all("title")
letters = soup.find_all("div", class_="company-desc-and-sort-container")
我收到以下错误:
print soup.find_all("title")
TypeError: 'NoneType' object is not callable
【问题讨论】:
-
你的 beautifulsoup 版本是什么?
标签: python beautifulsoup html-parsing