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

The Archive Base Latest Questions

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

I have an HTML file and i would like to parse through it using

  • 0

I have an HTML file and i would like to parse through it using python 3.2
sample :-

<td class="ln">15</td><td class="sf3b2"><code>&nbsp;</code></td>
<td class="ln">15</td><td class="sf3b2"><code>&nbsp;</code></td>

The job is to detect the numbers which are not tagged (in this case 15 only) and store them in another text file. I aint being able to decide which html parser to use (lxml,beautiful soup) as I am new to this. Could you please guide me about how to approach this problem.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-05T22:15:39+00:00Added an answer on June 5, 2026 at 10:15 pm

    You could try something like this.

    from BeautifulSoup import BeautifulSoup
    
    def getPrintUnicode(soup):
    
        body=''
        if isinstance(soup, unicode):
            soup = soup.replace('&#39;',"'")
            soup = soup.replace('&quot;','"')
            soup = soup.replace('&nbsp;',' ')
            soup = soup.replace('&gt;','>')
            soup = soup.replace('&lt;','<')
            body = body + soup
        else:
            if not soup.contents:
                return ''
            con_list = soup.contents
            for con in con_list:
                body = body + getPrintUnicode(con)
        return body
    
    print getPrintUnicode(BeautifulSoup('<td class="ln">15</td><td class="sf3b2"><code>&nbsp;</code></td>'))
    

    You can use this getPrintUnicode() function on the soup of whole page. It will return the complete content. Use exceptions and convert string to integers.
    eg.

    print int(getPrintUnicode(BeautifulSoup('<td class="ln">15</td><td class="sf3b2"><code>&nbsp;</code></td>')))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html file that has invoice details I would like to know
I have a OPML file that I would like to parse the links and
I have a string: <li>&File</li> . What I would like to do is analyse
I have an HTML file and would like to extract the text between <li>
i have a following pattern, inside the html file, that i would like to
I'm using Ruby and Nokogiri to parse HTML documents, and I would like to
django-userena does not have a views.py file. It uses instead html files, i would
I am using chrome version 18.0.1025.162 m I have html file with iframe within
Essentially, I have a dynamically generated local HTML form that I would like to
ASP.NET 4 & C# and I would like to know which CODE, Classes could

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.