【发布时间】:2020-12-31 02:03:17
【问题描述】:
我的示例代码:
>>> from bs4 import BeautifulSoup
>>> from requests import get
>>> url = 'https://nationaldaycalendar.com/what-is-national-today/'
>>> response = get(url)
>>> html_soup = BeautifulSoup(response.text, 'html.parser')
>>> national_container = html_soup.find_all('div', class_ = 'eventon_events_list')
>>> container = national_container.find_all(itemprop='description').get('content')
This line ^ Resulted in an error
抛出的错误:
Traceback (most recent call last):
File "<pyshell#28>", line 1, in <module>
container = national_container.find_all(itemprop='description').get('content')
File "C:\Users\hyuiu\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\element.py", line 2160, in __getattr__
raise AttributeError(
AttributeError: ResultSet object has no attribute 'find_all'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?
谁能帮我理解这个?
【问题讨论】:
标签: python web beautifulsoup screen-scraping