私は絶対初心者です。私はBeautifulSoupを使用してウェブサイトを擦ってみます。私はHTMLを取得しますが、divs
のクラスがcontent_class
のものをすべて取得したいと考えています。Website 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
?あなたはBeautifulSoupにはメソッド「find_all」がないので、「findAllの」方法があり、このエラーを取得している
2行目から最後の行に 'print(soup.find_all)'を置くと、何が印刷されますか? – unutbu
だから私は 'soup = BeautifulSoup(html)'を行い、次に 'print(soup.find_all)'を印刷し、 'None'と表示しました。 –