Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
parsing table
#1
A table has one tag <tbody> with 100 of <tr> in it but I only can find table and get the error below when parsing tags in the table. Is it possible some table cannot to parsed? I use python 3.6. Thanks

page = requests.get(url)
html = BeautifulSoup(page.content,'html.parser')
table = html.find_all('table')
print(len(table))
table.find('tbody')
1
Traceback (most recent call last):
File "C:/1 - Run/TradeOpen/Python Scripts/G&M - RealTime.py", line 12, in <module>
table.find('thead')
File "C:\Users\Ian\AppData\Local\Programs\Python\Python36\lib\site-packages\bs4\element.py", line 1807, in __getattr__
"ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?" % key
AttributeError: ResultSet object has no attribute 'find'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?
>>>
Reply


Messages In This Thread
parsing table - by ian - Apr-25-2018, 08:16 PM
RE: parsing table - by nilamo - Apr-25-2018, 08:21 PM
RE: parsing table - by ian - Apr-25-2018, 09:35 PM
RE: parsing table - by nilamo - Apr-26-2018, 02:57 AM
RE: parsing table - by ian - Apr-26-2018, 03:19 AM
RE: parsing table - by snippsat - Apr-26-2018, 05:19 AM
RE: parsing table - by ian - Apr-26-2018, 05:28 PM
RE: parsing table - by snippsat - Apr-26-2018, 08:05 PM
RE: parsing table - by nilamo - Apr-27-2018, 06:44 AM
RE: parsing table - by ian - Apr-27-2018, 12:16 PM
RE: parsing table - by snippsat - Apr-27-2018, 01:05 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Help: Beautiful Soup - Parsing HTML table ironfelix717 2 2,697 Oct-01-2020, 02:19 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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