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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:15:00+00:00 2026-06-05T16:15:00+00:00

s = <tbody> <tr> <td style=border-bottom: none> <span class=graytext style=font-weight: bold;> Reply #3 –

  • 0
 s = """
      <tbody>
      <tr>
       <td style="border-bottom: none">
       <span class="graytext" style="font-weight: bold;"> Reply #3 - </span>
        <span class="graytext" style="font-size: 11px">
        05/13/09  2:02am
        <br>
       </span>
      </td>
     </tr>
    </tbody>
 """

In the HTML string I need to take out the date string.

I tried in this way

  import lxml
  doc = lxml.html.fromstring(s)
  doc.xpath('//span[@class="graytext" and @style="font-size: 11px"]')

But this is not working. I should have to take only the Datestring.

  • 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-05T16:15:01+00:00Added an answer on June 5, 2026 at 4:15 pm

    Your query is selecting the span, you need to grab the text from it:

    >>> doc.xpath('//span[@class="graytext" and @style="font-size: 11px"]')
    [<Element span at 1c9d4c8>]
    

    Most queries return a sequence, I normally use a helper function that gets the first item.

    from lxml import etree
    s = """
    <tbody>
     <tr>
       <td style="border-bottom: none">
       <span class="graytext" style="font-weight: bold;"> Reply #3 - </span>
        <span class="graytext" style="font-size: 11px">
        05/13/09  2:02am
        <br>
       </span>
      </td>
     </tr>
    </tbody>
    """
    doc = etree.HTML(s)
    
    def first(sequence,default=None):
      for item in sequence:
        return item
      return default
    

    Then:

    >>> doc.xpath('//span[@class="graytext" and @style="font-size: 11px"]')
    [<Element span at 1c9d4c8>]
    >>> doc.xpath('//span[@class="graytext" and @style="font-size: 11px"]/text()')
    ['\n    05/13/09  2:02am\n    ']
    >>> first(doc.xpath('//span[@class="graytext" and @style="font-size: 11px"]/text()'),'').strip()
    '05/13/09  2:02am'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

<table cellpadding=0 cellspacing=0 border=1 class=display id=FormsData style=margin-bottom:5px;> <thead> <tr id=thFormsData> </tr> <tr> </tr> </thead>
I have following CSS: table tbody tr:last-child td { padding-top: 7px; border-bottom: 0; }
$(function() { $(table.section thead).click(function() { if ($(this).next(table.section tbody).style.display == block){ $(this).next(table.section tbody).slideUp(slow); } if
team = hxs.select ('//table[@class=tablehead/tbody/tr[contains[.@class, player]') The structure of the web site I whose table
If the following works: alert( data.query.results.tbody[1].tr[0].td[0].span.img.src ); Why will this not work? var image
i have this css : .table1 thead th:first-child{ -webkit-border-bottom-right-radius:8px; -webkit-border-top-right-radius:8px; -moz-border-radius:8px 0px 8px 0px;
I have a markup: <table cellpadding=0 cellspacing=0 class=table_report_line> <tbody> <tr> <td> <div class=dvlefttable> </div>
<body> <div id=container> <div id=body> <center> <table width=650 border=0 cellspacing=0 cellpadding=5> <tbody> <tr> <td
$(#table_exams tbody tr).click(function (event) { window.location.href=# +$(this).attr(exam_ID); window.location.href=/medilab/prototypes/exams/edit?examId= + $(this).attr(exam_ID) +&referer= + referer; row_select(this);
I'd like to animate table body TBody change with jQuery. I have a table:

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.