我是絕對的初學者。我嘗試使用BeautifulSoup並刮掉一個網站。我確實得到了HTML,但是我現在想要獲得所有類別爲content_class
的divs
。使用BeautifulSoup網站刮擦:TypeError:'NoneType'對象無法調用
這裏是我的嘗試:
import requests
from BeautifulSoup import BeautifulSoup
#Request the page and parse the HTML
url = 'mywebsite'
response = requests.get(url)
html = response.content
#Beautiful Soup
soup = BeautifulSoup(html)
soup.find_all('div', class_="content_class")
然而,這並不工作。 我得到:
Traceback (most recent call last): File "scrape.py", line 11, in soup.find_all('div', class_="content_class") TypeError: 'NoneType' object is not callable
我在做什麼錯?
如果你在倒數第二行放上'print(soup.find_all)',打印什麼? – unutbu
所以我做了'soup = BeautifulSoup(html)',然後 'print(soup.find_all)',打印的是'None'。 –