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
#1
Hi,

I am scraping data from a web page but none of the items have an ID. I'm struggling to find an example so here goes...

The table looks like such:

Output:
<table style = " border-collapse: collapse;" border="0" cellPadding="0" summary="Transactions statistics summary table" class="750WidthClass" > <tr bgcolor="330066" > <td id="LraTransaction Name&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Transaction Name&nbsp;</span></td> <td id="Status" class="table_header" vAlign="top" width="80"><span class="Verdana2">SLA Status</span></td> <td id="LraMinimum&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Minimum&nbsp;</span></td> <td id="LraAverage&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Average&nbsp;</span></td> <td id="LraMaximum&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Maximum&nbsp;</span></td> <td id="LraStd. Deviation&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Std. Deviation&nbsp;</span></td> <td id="Lra80 Percent&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">80 Percent&nbsp;</span></td> <td id="LraPass&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Pass&nbsp;</span></td> <td id="LraFail&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Fail&nbsp;</span></td> <td id="LraStop&nbsp;" class="table_header_for_html_report" vAlign="top"><span class="Verdana2">Stop&nbsp;</span></td> </tr> </table>
All examples online point to using ID. But that doesn't exist.

There are several tables on the page but to uniquely identify the one above, I'd want something like:

find/findall in table. Unique identifier: summary="Transactions statistics summary table"

for each row in the table, extract values. Unique identifier: class="Verdana2">

I want to retrieve the values:
Transaction Name&nbsp;
LraMinimum&nbsp;
Average&nbsp;
Maximum&nbsp;
Std. Deviation&nbsp;
80 Percent&nbsp;
Pass&nbsp;
Fail&nbsp;
Stop&nbsp;

Hope that makes sense?

Cheers,
J
Reply


Messages In This Thread
BeautifulSoup - extract table but not using ID - by jonesin1974 - Jan-04-2018, 02:49 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to extract style attribute with BeautifulSoup knight2000 1 3,103 Dec-28-2022, 03:06 AM
Last Post: knight2000
  Extract data from a table Bob_M 3 2,680 Aug-14-2020, 03:36 PM
Last Post: Bob_M
  Extract data with Selenium and BeautifulSoup nestor 3 3,921 Jun-06-2020, 01:34 AM
Last Post: Larz60+
  Beautifulsoup table question tantony 5 2,809 Sep-30-2019, 03:26 PM
Last Post: tantony
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 3 3,224 Aug-25-2019, 01:13 AM
Last Post: kawasso
  How to get hyperlinks in to the table extracted by BeautifulSoup KenniT 2 4,938 Apr-04-2018, 10:05 AM
Last Post: DeaD_EyE
  BeautifulSoup - Table tkj80 6 9,770 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