Python Forum
BeautifulSoup - extract table but not using ID
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
BeautifulSoup - extract table but not using ID
#3
Quote:There are several tables on the page but to uniquely identify the one above,
An ID is the only thing that can surely identify 100% from others. Sometimes you get lucky and the class name is the only one used in that tag you are searching for on that page, and sometimes you just have to pick the 4th table out from your results.

soup.find('table', {'class':'750WidthClass'})
but if the other tables have that same class, then you will need to get them all, then get the nth number of the tables with that class.
tables = soup.find_all('table', {'class':'750WidthClass'})
print(tables[3])
assuming it is the 4th table with that class
Recommended Tutorials:
Reply


Messages In This Thread
RE: BeautifulSoup - extract table but not using ID - by metulburr - Jan-04-2018, 05:05 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to extract style attribute with BeautifulSoup knight2000 1 3,155 Dec-28-2022, 03:06 AM
Last Post: knight2000
  Extract data from a table Bob_M 3 2,706 Aug-14-2020, 03:36 PM
Last Post: Bob_M
  Extract data with Selenium and BeautifulSoup nestor 3 3,945 Jun-06-2020, 01:34 AM
Last Post: Larz60+
  Beautifulsoup table question tantony 5 2,837 Sep-30-2019, 03:26 PM
Last Post: tantony
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 3 3,258 Aug-25-2019, 01:13 AM
Last Post: kawasso
  How to get hyperlinks in to the table extracted by BeautifulSoup KenniT 2 4,974 Apr-04-2018, 10:05 AM
Last Post: DeaD_EyE
  BeautifulSoup - Table tkj80 6 9,817 Oct-21-2016, 01:23 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

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