Apr-10-2020, 09:40 PM
Dears,
I'm very newbie to the Python Language and I have spent some time teaching myself. Every time I face an error I try to dig for the solution online, but this time I really gave up.
I'm trying to do a web scraping and I got a stuck with an error that have driven me crazy, I will show the code and the result.
I'm very newbie to the Python Language and I have spent some time teaching myself. Every time I face an error I try to dig for the solution online, but this time I really gave up.
I'm trying to do a web scraping and I got a stuck with an error that have driven me crazy, I will show the code and the result.
import requests from bs4 import BeautifulSoup from Data import row # Collect and parse first page page = requests.get('https://web.archive.org/web/20121007172955/https://www.nga.gov/collection/anZ1.htm') soup = BeautifulSoup(page.text, 'html.parser') # Pull all text from the BodyText div artist_name_list = soup.find(class_='BodyText') # Pull text from all instances of <a> tag within BodyText div artist_name_list_items = artist_name_list.find_all('a') # Create for loop to print out all artists' names for artist_name in artist_name_list_items: print(artist_name.prettify())
Error:Traceback (most recent call last):
File "C:/Users/HP/PycharmProjects/PyShop/Test1.py", line 15, in <module>
artist_name_list_items = artist_name_list.find_all('a')
AttributeError: 'NoneType' object has no attribute 'find_all'
I run python 3.8, any suggestings?