Aug-28-2018, 05:27 PM
Good morning / afternoon. I am working on a activity where I am supposed to get siblings from a teaching website. I am getting a traceback error and I don't understand it. I have tried everything I can think of.
Here is the code I'm trying to run. Notice at the top - I have 4 rows rather than the two my activity shows. Yesterday, I learned that using this will help with dealing with errors so I've chosen to use these in all the code I create. The two rows my activity calls for is "import urlopen" and "from bs4 import BeautifulSoup". I have tried removing my additions but it didn't resolve the error.
Here is the code I'm trying to run. Notice at the top - I have 4 rows rather than the two my activity shows. Yesterday, I learned that using this will help with dealing with errors so I've chosen to use these in all the code I create. The two rows my activity calls for is "import urlopen" and "from bs4 import BeautifulSoup". I have tried removing my additions but it didn't resolve the error.
from urllib.request import urlopen from urllib.error import HTTPError from urllib.error import URLError from bs4 import BeautifulSoup html = urlopen('http://www.pythonscraping.com/pages/page3.html') bs = BeautifulSoup(html, 'html.parser') for sibling in bs.find('table', {'id':'giftList'}).tr.nest_siblings: print(sibling)This is the error I get.
Error:== RESTART: C:\Python365\Web Scraping with Python\Dealing with siblings.py ==
Traceback (most recent call last):
File "C:\Python365\Web Scraping with Python\Dealing with siblings.py", line 9, in <module>
for sibling in bs.find('table', {'id':'giftList'}).tr.nest_siblings:
TypeError: 'NoneType' object is not iterable
>>>
I will most appreciate any help you provide!