Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Table data with BeatifulSoup
#1
Hi All,

I'm learning Python right now (and this is actually my first threat so let me know if there is a way to ask my question in a clearer manner)
and I want to retrieve the rates from the table in attached link:
https://www.global-rates.com/interest-ra...libor.aspx

however with the following code:

import urllib.request as ur
from bs4 import BeautifulSoup

url = input('Enter URL: ')

html = ur.urlopen(url).read()
soup = BeautifulSoup(html, 'html.parser')

data = []
table = soup.find('table', attrs={'class':'lineItemsTable'})
table_body = table.find('tbody')

rows = table_body.find_all('tr')
for row in rows:
cols = row.find_all('td')
cols = [ele.text.strip() for ele in cols]
data.append([ele for ele in cols if ele])
I receive this error:

Error:
Traceback (most recent call last): File "....\global_rates.py", line 11, in table_body = table.find('tbody') AttributeError: 'NoneType' object has no attribute 'find'
Can anybody help me on that?

Thanks a lot!
Gerald
Reply


Messages In This Thread
Table data with BeatifulSoup - by gerry84 - Sep-24-2019, 04:17 PM
RE: Table data with BeatifulSoup - by buran - Sep-24-2019, 04:34 PM
RE: Table data with BeatifulSoup - by gerry84 - Sep-24-2019, 04:38 PM
RE: Table data with BeatifulSoup - by Larz60+ - Sep-24-2019, 04:57 PM
RE: Table data with BeatifulSoup - by gerry84 - Sep-24-2019, 05:30 PM
RE: Table data with BeatifulSoup - by metulburr - Sep-24-2019, 07:19 PM
RE: Table data with BeatifulSoup - by gerry84 - Sep-24-2019, 08:07 PM
RE: Table data with BeatifulSoup - by gerry84 - Sep-24-2019, 10:48 PM
RE: Table data with BeatifulSoup - by gerry84 - Oct-22-2019, 06:00 PM
RE: Table data with BeatifulSoup - by Larz60+ - Oct-22-2019, 06:09 PM
RE: Table data with BeatifulSoup - by gerry84 - Oct-22-2019, 09:03 PM
RE: Table data with BeatifulSoup - by Larz60+ - Oct-23-2019, 10:09 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Scraping data from table into existing dataframe vincer58 1 1,960 Jan-09-2022, 05:15 PM
Last Post: vincer58
  Inserting data from a table to another (in same db) firebird 5 2,425 Oct-05-2020, 06:04 AM
Last Post: buran
  Extract data from a table Bob_M 3 2,627 Aug-14-2020, 03:36 PM
Last Post: Bob_M
  Scraping a dynamic data-table in python through AJAX request filozofo 1 3,823 Aug-14-2020, 10:13 AM
Last Post: kashcode
  Want to scrape a table data and export it into CSV format tahir1990 9 5,134 Oct-22-2019, 08:03 AM
Last Post: buran
  Using flask to add data to sqlite3 table with PRIMARY KEY catafest 1 3,704 Sep-09-2019, 07:00 AM
Last Post: buran
  sqlalchemy DataTables::"No data available in table" when using self-joined table Asma 0 2,550 Nov-22-2018, 02:46 PM
Last Post: Asma
  beatifulsoup scrap td tag. piuk3man 1 3,844 Jun-11-2018, 06:16 AM
Last Post: buran
  Insert data in a table after a user is created from djando admin prithvi 0 3,515 Aug-11-2017, 06:25 PM
Last Post: prithvi
  Installation of bs4 and BeatifulSoup landlord1984 7 8,667 Jan-09-2017, 07:41 AM
Last Post: landlord1984

Forum Jump:

User Panel Messages

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