Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6194387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:17:19+00:00 2026-05-24T03:17:19+00:00

I want to extract data from HTML table using Python script and save it

  • 0

I want to extract data from HTML table using Python script and save it as variables(that I can later use in same script after loading them in if they exist) into a separate file. Also I want the script to ignore the first row of table(Component, Status, Time / Error). I would prefer not to use external libraries.

The output into a new file should be like so:

SAVE_DOCUMENT_STATUS = "OK"
SAVE_DOCUMENT_TIME = "0.408"
GET_DOCUMENT_STATUS = "OK"
GET_DOCUMENT_TIME = "0.361"
...

And heres the input to the script:

<table border=1>
<tr>
<td><b>Component</b></td>
<td><b>Status</b></td>
<td><b>Time / Error</b></td>
</tr>
<tr><td>SAVE_DOCUMENT</td><td>OK</td><td>0.408 s</td></tr>
<tr><td>GET_DOCUMENT</td><td>OK</td><td>0.361 s</td></tr>
<tr><td>DVK_SEND</td><td>OK</td><td>0.002 s</td></tr>
<tr><td>DVK_RECEIVE</td><td>OK</td><td>0.002 s</td></tr>
<tr><td>GET_USER_INFO</td><td>OK</td><td>0.135 s</td></tr>
<tr><td>NOTIFICATIONS</td><td>OK</td><td>0.002 s</td></tr>
<tr><td>ERROR_LOG</td><td>OK</td><td>0.001 s</td></tr>
<tr><td>SUMMARY_STATUS</td><td>OK</td><td>0.913 s</td></tr>
</table>

I tried to do it in bash, but since I need to compare *_TIME variables to maximum time, then it fails, because they’re float numbers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:17:20+00:00Added an answer on May 24, 2026 at 3:17 am

    Using lxml:

    import lxml.html as lh
    
    content='''\
    <table border=1>
    <tr>
    <td><b>Component</b></td>
    <td><b>Status</b></td>
    <td><b>Time / Error</b></td>
    </tr>
    <tr><td>SAVE_DOCUMENT</td><td>OK</td><td>0.408 s</td></tr>
    <tr><td>GET_DOCUMENT</td><td>OK</td><td>0.361 s</td></tr>
    <tr><td>DVK_SEND</td><td>OK</td><td>0.002 s</td></tr>
    <tr><td>DVK_RECEIVE</td><td>OK</td><td>0.002 s</td></tr>
    <tr><td>GET_USER_INFO</td><td>OK</td><td>0.135 s</td></tr>
    <tr><td>NOTIFICATIONS</td><td>OK</td><td>0.002 s</td></tr>
    <tr><td>ERROR_LOG</td><td>OK</td><td>0.001 s</td></tr>
    <tr><td>SUMMARY_STATUS</td><td>OK</td><td>0.913 s</td></tr>
    </table>
    '''
    tree=lh.fromstring(content)
    for key, status, t in zip(*[iter(tree.xpath('//td/text()'))]*3):
        print('''{k}_STATUS = "{s}"
    {k}_TIME = "{t}"'''.format(k=key,s=status,t=t.rstrip(' s')))
    

    yields

    SAVE_DOCUMENT_STATUS = "OK"
    SAVE_DOCUMENT_TIME = "0.408"
    GET_DOCUMENT_STATUS = "OK"
    GET_DOCUMENT_TIME = "0.361"
    DVK_SEND_STATUS = "OK"
    DVK_SEND_TIME = "0.002"
    DVK_RECEIVE_STATUS = "OK"
    DVK_RECEIVE_TIME = "0.002"
    GET_USER_INFO_STATUS = "OK"
    GET_USER_INFO_TIME = "0.135"
    NOTIFICATIONS_STATUS = "OK"
    NOTIFICATIONS_TIME = "0.002"
    ERROR_LOG_STATUS = "OK"
    ERROR_LOG_TIME = "0.001"
    SUMMARY_STATUS_STATUS = "OK"
    SUMMARY_STATUS_TIME = "0.913"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'd like to extract the text from an HTML file using Python. I want
i want to make a program that can extract the data from a removable
I have a couple of websites that I want to extract data from and
I want to use PHP (possibly with Curl/XPath?) to extract data from Wikipedia pages.
I want to use Perl to extract information from a Certificate Signing Request ,
I want to parse the html table using html agility pack. I want to
Is there a way to extract desired data from a raw html which has
I want to extract data from such regex: <td>[a-zA-Z]+</td><td>[\d]+.[\d]+</td><td>[\d]+</td><td>[\d]+.[\d]+</td> I've found related question extract
I am trying to extract data from XML file and save it my C#
I want to use LINQ to group data from a DataTable (columns: userid, chargetag,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.