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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T22:03:28+00:00 2026-05-28T22:03:28+00:00

I have an old website originally created in MS Frontpage that I’m trying to

  • 0

I have an old website originally created in MS Frontpage that I’m trying to defrontpagify. I’ve written a BeautifulSoup script that does most of it. Only thing left is to remove empty tables, eg tables with no text content or data in any of their td tags.

The problem I’m stuck on is that what I’ve tried so far removes the table if at least one its td tags contains no data, even if others do. That removes all the tables in the entire document, including ones with data I want to preserve.

tags = soup.findAll('table',text=None,recursive=True) 
[tag.extract() for tag in tags]

Any suggestions how to only remove tables in which none of the td tags contain any data? (I don’t care if they contain img or empty anchor tags, as long as there’s no text).

  • 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-05-28T22:03:28+00:00Added an answer on May 28, 2026 at 10:03 pm

    Use the .text property. It retrieves all text content (recursive) within that element.

    Example:

    from BeautifulSoup import BeautifulSoup as BS
    
    html = """
    <table id="empty">
      <tr><td></td></tr>
    </table>
    
    <table id="with_text">
      <tr><td>hey!</td></tr>
    </table>
    
    <table id="with_text_in_one_row">
      <tr><td></td></tr>
      <tr><td>hey!</td></tr>
    </table>
    
    <table id="no_text_but_img">
      <tr><td><img></td></tr>
    </table>
    
    <table id="no_text_but_a">
      <tr><td><a></a></td></tr>
    </table>
    
    <table id="text_in_a">
      <tr><td><a>hey!</a></td></tr>
    </table>
    
    """
    
    soup = BS(html)
    for table in soup.findAll("table" ,text=None,recursive=True):
        if table.text:
            print table["id"]
    

    Outputs:

    with_text
    with_text_in_one_row
    text_in_a
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a old website that generate its own RSS everytime a new post
I currently have a news website setup in PHP/MYSQL that's a bit old and
I have an ActiveX control that runs on a website, where the old version
I have an old website that hasn't gotten much love over the years and
I have a rather old website that I've fed up refactoring so I'm rebuilding.
I have an old website - written in asp. The contact form uses a
We have a 10+ years old ASP.NET website project, with lots of unused /
We are done migrating a website from old CMS to SDL Tridion. We have
I have a website developed in Umbraco CMS, I would like to re-write old
I have a web site with four options. A friend mentioned that his old

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.