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

  • Home
  • SEARCH
  • 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 9122277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:03:53+00:00 2026-06-17T06:03:53+00:00

im trying to match some data from a html output but im not sure

  • 0

im trying to match some data from a html output but im not sure what i could do to perform it right. So, im using the following block of code to extract the content of access and groups information:

import requests
import lxml.etree as LE
import lxml.html as LH

url = "http://theurl"
r = requests.get(url,auth=('user', 'pass'))
html = r.text

root = LH.fromstring(html)
LE.strip_tags(root, 'b')
data_list = root.xpath("""//td[text()='grouplist']
                             /following-sibling::*""")[0]

accessList= data_list.xpath("""//td[text()='access']
                                 /following-sibling::*/text()""")

groups = data_list.xpath("""//td[text()='groups']
                                 /following-sibling::*/text()""")

if i print the accessList, i have the data that i want:

print accessList
['Administrators', 'group_a', 'group_b', 'group_c']

but when i print the groups, the returning result would be:

print groups:
['\n','\n','\n']

Having that information, what could be done in order to get:

print groups
['group_a', 'group_b', 'group_c']

Here, you can see the returning html result

<TABLE bgcolor="#dddddd" border="1" />
<TR>
   <TD valign="top"><B>grouplist</B></TD>
   <TD>
      <TABLE />
<TR>
   <TD>
      <TABLE bgcolor="#dddddd" border="1" />
<TR>
   <TD valign="top"><B>access</B></TD>
   <TD>Administrators</TD>
</TR>
<TR>
   <TD valign="top"><B>inUse</B></TD>
   <TD>true</TD>
</TR>
<TR>
   <TD valign="top"><B>groups</B></TD>
   <TD>
      <TABLE>
         <TR>
            <TD>group_a</TD>
         </TR>
         <TR>
            <TD>group_b</TD>
         </TR>
         <TR>
            <TD>group_c</TD>
         </TR>
      </TABLE>
   </TD>
</TR>
<TR>
   <TD valign="top"><B>deny</B></TD>
   <TD>
      <TABLE>
      </TABLE>
   </TD>
</TR>

EDIT : Html code can be tested here: html tester

Thanks in advance.

  • 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-17T06:03:54+00:00Added an answer on June 17, 2026 at 6:03 am
    groups = data_list.xpath("""//td[text()='groups']
                                     /following-sibling::td/table/tr/td/text()""")
    

    or, a little less specifically,

    groups = data_list.xpath("""//td[text()='groups']
                                     /following-sibling::*//td/text()""")
    

    works. If that too specific for your purpose, you could instead define groups this way:

    groups = data_list.xpath("""//td[text()='groups']
                                     /following-sibling::*""")[0]
    

    and then use text_content:

    groups = groups.text_content().split()
    

    However, splitting the text content on whitespace may not work well if group_a, group_b and/or group_c were replaced with text that itself contains whitespace.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to exclude some data from a string using regex. var match =
I am trying to catch some data from iostat output: # iostat -m avg-cpu:
I'm trying to import address data from some a database where there was not
I am trying to parse some output data from and PBX and I have
I'm trying to get some data from a file, then parse it and pass
I'm trying to get some custom routing going on in Magento using the following
i'm trying to migrate some data from two tables in an OLD database, to
I am trying to parse some data from external site to local script. Local
I'm trying to write some data to a CSV file from TCL script with
I'm trying to scrape some content off another site and I'm not sure why

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.