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 8454595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:04:01+00:00 2026-06-10T12:04:01+00:00

Im trying to extract some fields from the output at the end of this

  • 0

Im trying to extract some fields from the output at the end of this question with the following code:

doc = LH.fromstring(html2)
tds = (td.text_content() for td in doc.xpath("//td[not(*)]"))

for a,b,c in zip(*[tds]*3):
    print (a,b,c)

What i expect is to extract only the fields notificationNodeName,notificationNodeName,packageName,notificationEnabled

The main problem with that is because i want to put the result into a database. and i need to, instead receiveing:

Actual code returns:

('JDBCAdapter', 'JDBCAdapter', 'Package:Notif')
('Package', 'yes', 'Package_2:Notif')
('Package_2', 'yes')

What i need:

('Package:Notif','Package', 'yes')
('Package_2:Notif','Package_2', 'yes')

An unly solution that i found was:

doc = LH.fromstring(html2)
tds = (td.text_content() for td in doc.xpath("//td"))

for td, val in zip(*[tds]*2):
    if td == 'notificationNodeName':
        notificationNodeName = val
    elif td == 'packageName':
        packageName = val
    elif td == 'notificationEnabled':
        notificationEnabled = val
        print (notificationNodeName,packageName,notificationEnabled)

It works but doenst seen right for me, im sure it can be a better way to do it.

Original HTML Output:

<tbody><tr>
<td valign="top"><b>adapterTypeName</b></td>
<td>JDBCAdapter</td>
</tr>
<tr>
<td valign="top"><b>adapterTypeNameList</b></td>
<td>
<table>
<tbody><tr>
<td>JDBCAdapter</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td valign="top"><b>notificationDataList</b></td>
<td>
<table>
<tbody><tr>
<td><table bgcolor="#dddddd" border="1">
<tbody><tr>
<td valign="top"><b>notificationNodeName</b></td>
<td>package:Notif</td>
</tr>
<tr>
<td valign="top"><b>packageName</b></td>
<td>Package</td>
</tr>
<tr>
<td valign="top"><b>notificationEnabled</b></td>
<td>unsched</td>
</tr>
</tbody></table>
</td>
</tr>
<tr>
<td><table bgcolor="#dddddd" border="1">
<tbody><tr>
<td valign="top"><b>notificationNodeName</b></td>
<td>Package_2:notif</td>
</tr>
<tr>
<td valign="top"><b>packageName</b></td>
<td>package_2</td>
</tr>
<tr>
<td valign="top"><b>notificationEnabled</b></td>
<td>yes</td>
</tr>

and continues to more ... non relevant repetitive data.
  • 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-06-10T12:04:03+00:00Added an answer on June 10, 2026 at 12:04 pm

    I would recommend using the excellent lxml and it’s cssselect functionality for basically most HTML parsing.

    You can then select each field you are interested in thusly:

    from lxml import html
    root = html.parse(open('your/file.html')).getroot()
    
    sibling_content = lambda x: [b.getparent().getnext().text_content() for b in
                                 root.cssselect("td b:contains('{0}')".format(x))]
    
    fields = ['notificationNodeName', 'packageName', 'notificationEnabled']
    
    for item in zip(*[sibling_content(field) for field in fields]):
        print item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to extract some files from a jar-file downloaded using java-webstart. below code
I'm trying to extract some FastQ files from bam files. Picard can do this
I'm trying to write some code to extract Exif information from a JPG. Exif
A basic question about AND logical operator. I'm trying to extract some fields in
I'm trying to extract some information from bash command output: uptime | awk '{print
I have an xml from which I am trying to extract some information through
I'm trying to figure out how to extract some data from a string according
I'm trying to use WWW::Mechanize to extract some links from the HTML page using
I'm trying to extract some variables in my C++ code nested in blocks. For
I'm trying to extract some information from a webpage using php cURL+preg_match or any

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.