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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T17:49:03+00:00 2026-06-16T17:49:03+00:00

I am trying to parse a broken html page which has a comment inside

  • 0

I am trying to parse a broken html page which has a comment inside anther comment and all the famous htmlparsers like beautifulsoup, lxml and HTMLParser are giving syntax errors. Following is the code. How do I ignore the part of corrupt code and parse rest of the page?

<html xmlns="http://www.w3.org/1999/xhtml"><head>

<script language="JavaScript">
<!--
     function setTimeOffsetVars (Link) { 
   // code removed
 } 

<!-- Image Preloader - takes an array of images to preload --> 
    function warningCheck(e, warnMsg) {
   // code removed
}
-->
</script>

</head>

<body topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<!-- lot of useful code -->
</body></html>
  • 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-16T17:49:04+00:00Added an answer on June 16, 2026 at 5:49 pm

    I have no errors with this html. I tried beautifulsoup4 and lxml.

    from bs4 import BeautifulSoup
    soup = BeautifulSoup(s)
    print soup.prettify()
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <script language="JavaScript">
       &lt;!--
         function setTimeOffsetVars (Link) { 
       // code removed
     } 
    
    &lt;!-- Image Preloader - takes an array of images to preload --&gt; 
        function warningCheck(e, warnMsg) {
       // code removed
    }
    --&gt;
      </script>
     </head>
     <body bottommargin="0" leftmargin="0" marginheight="0" marginwidth="0" rightmargin="0" topmargin="0">
      <!-- lot of useful code -->
     </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to parse words which can be broken up over multiple lines with
I'm trying parse a html form that looks like that: <select name=country> <option value=1>Afghanistan</option>
Trying to parse an HTML document and extract some elements (any links to text
I am trying to parse specific XML file which is located in sub directories
I'm trying to parse a file that looks like this: || Column Header A
i'm trying to get web-page data in string that than i could parse it.
I am trying parse out some text that is in an html file. The
Hey all i am trying to parse the following CDATA description: <description> <![CDATA[ <p><b>Submission
I'm trying parse html with Jsoup lib. Everything works perfect, but something that does't
Am trying to parse this HTML document to get the contents of flight, time,

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.