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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:39:46+00:00 2026-06-07T16:39:46+00:00

I am trying to parse a simple html table using beautifulsoup but I have

  • 0

I am trying to parse a simple html table using beautifulsoup but I have some problems

Here is my Input

<table id="people" class="tt" width="99%" border="0" cellpadding="0" cellspacing="1">
 <tr>
  <td colspan="3" bgcolor="#d3d3d3">
   <p align="center" style="border: 1px solid #c0c0c0; padding: 0.02in">
    <a name="faculty">
    </a>
    <b>
     Faculty
    </b>
   </p>
  </td>
 </tr>
 <tr>
  <td>
   <p align="center">
    <font color="#000080">
     <a href="http://www.website.com/%7Empop">
      <font color="#000080">
       <img src="images/mpop.jpg" name="graphics1" align="bottom" width="70" height="85" border="1" />
      </font>
     </a>
    </font>
   </p>
  </td>
  <td>
   <p>
    <b>
     John Doe, Ph.D.
    </b>
    <br />
    Associate Professor, Computer
                Science
    <br />

   </p>
  </td>
  <td>
   <p>
    Office:  Sciences Bldg.
    <br />
    Phone:
                xxx-xxx-xxxx
    <br />
    jd [at] website.com
    <br />
       </p>
  </td>
 </tr>
 <tr>
  <td>
   <p align="center">
    <font color="#000080">
     <a href="http://www.website.com/%7Ercolwell">
      <font color="#000080">
       <img src="images/rcolwell.jpg" name="graphics2" align="bottom" width="70" height="97" border="1" />
      </font>
     </a>
    </font>
   </p>
  </td>
  <td>
   <p>
    <b>
     Jane Doe, Ph.D.
    </b>
    <br />
     Professor
    <br />
  School of Public Health
    <br />
   </p>
  </td>
  <td>
   <p>
    Sciences Bldg
    <br />
    jd [at]
                website.com
    <br />

    </a>
   </p>
  </td>
 </tr>
</table>

Here is my code

t = soup.findAll("table",id="people")
for table in t:
    rows = table.findAll("tr")
    for tr in rows:
        cols = tr.findAll("td")
        for td in cols:
            print(str(td.find(text=True))) # tried also print(td.find(text=True))
            print(",")
        print("\n")

This will generate output with only commas without the text actually, but when I put print(td) I do find the information that I need to output but in html format with all the tags, can anyone point me to the right thing to do here ? I want to extract only the cell content.

Cheers

  • 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-07T16:39:48+00:00Added an answer on June 7, 2026 at 4:39 pm

    Maybe you are looking for s.t. like this:

    from BeautifulSoup import BeautifulSoup
    soup = BeautifulSoup("<table id=people><tr><td>x<a>y</a>z</td><td>x<a>y</a>z</td></tr></table>")
    t = soup.findAll("table",id="people")
    for table in t:
       rows = table.findAll("tr")
       for tr in rows:
          cols = tr.findAll("td")
          print(','.join([td.text for td in cols]))
    

    Alternatively you can use u''.join(map(unicode, td.contents)) depending on what exactly you want to get printed.

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

Sidebar

Related Questions

New to Python, have a simple, situational question: Trying to use BeautifulSoup to parse
I'm trying to parse a really simple HTML document with some xpath. There are
Here is my Html code. What I am trying sounds simple but I am
I'm trying to make a simple Python-based HTML parser using regular expressions. My problem
Trying to parse an HTML document and extract some elements (any links to text
OK I have been trying to parse a html tag which in it contains
I have been trying to get a simple spider to run with scrapy, but
I am new to XML and have been trying some simple examples and they
I'm trying to parse this HTML block: <div class=v120WrapperInner><a href=/redirect?q=http%3A%2F%2Fwww.google.com%2Faclk%3Fsa%3DL%26ai%3DCKJh--O7tSsCVIKeyoQTwiYmRA5SnrIsB1szYhg2d2J_EAhABIJ7rxQ4oA1CLk676B2DJntmGyKOQGcgBAaoEFk_Qyu5ipY7edN5ETLuchKUCHbY4SA#0%26num%3D1%26sig%3DAGiWqtwtAf8NslosN7AuHb7qC7RviHVg7A%26q%3Dhttp%3A%2F%2Fwww.youtube.com%2Fwatch%253Fv%253D91sYT_8CN8Q%2526feature%253Dpyv%2526ad%253D3409309746%2526kw%253Dsusan%25252#0boyle&amp;adtype=pyv&amp;event=ad&amp;usg=bR7ErKA_3szWtQMGe2lt1dpxzHc= title=The Valley Downs Chicago><img
I'm trying to parse some information from an HTML page. The only problem is

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.