Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Traceback error
#1
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.

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!
Reply
#2
Well without diving to deeply I would start by trying to figure out which variable is of type None. Essentially, the error is telling you that there is a variable that you are attempting to iterate that is of type None on line 9.
Reply
#3
it is next_siblings
I think at the moment it looks for a tag nest_siblings
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
buran - that was it exactly! I need to look closer at what I'm typing!

Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Traceback error tjnichols 3 5,355 Sep-11-2018, 07:04 PM
Last Post: tjnichols
  Traceback error tjnichols 55 28,261 Jun-25-2018, 11:52 PM
Last Post: Larz60+
  Traceback error - I don't get it tjnichols 2 3,104 May-24-2018, 08:10 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020