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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:10:32+00:00 2026-05-17T17:10:32+00:00

pQuery is a pragmatic port of the jQuery JavaScript framework to Perl which can

  • 0

pQuery is a pragmatic port of the jQuery JavaScript framework to Perl which can be used for screen scraping.

pQuery quite sensitive to malformed HTML. Consider the following example:

use pQuery;

my $html_malformed = "<html><head><title>foo</title></head><body>bar</body></html>>";
my $page = pQuery($html_malformed);
my $title = $page->find("title");
print "The title is: ", $title->html, "\n";

pQuery won’t find the title tag in the example above due to the double “>>” in the malformed HTML.

To make my pQuery based applications more tolerant to malformed HTML I need to pre-process the HTML by cleaning it up before passing it to pQuery.

Starting with the code fragment given above, what is the most robust pure-perl way to clean-up the HTML to make it parse:able by pQuery?

  • 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-17T17:10:33+00:00Added an answer on May 17, 2026 at 5:10 pm

    I’d report this as a bug in pQuery. Here’s a workaround:

    use HTML::TreeBuilder;
    use pQuery;
    
    my $html_malformed = "<html><head><title>foo</title></head><body>bar</body></html>>";
    my $html_cleaned = HTML::TreeBuilder->new_from_content($html_malformed);
    my $page = pQuery($html_cleaned->as_HTML);
    $html_cleaned->delete;
    my $title = $page->find("title");
    print "The title is: ", $title->html, "\n";
    

    This doesn’t make a lot of sense, since pQuery already uses HTML::TreeBuilder as its underlying parsing mechanism, but it does work.

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

Sidebar

Related Questions

I'm using pQuery (a Perl port of jQuery) to select elements and retrieve text
I have some code which utilizes parameterized queries to prevent against injection, but I
I am using the Entity Framework and have got a loop that looks at
I'm scraping a page with Python's pyquery, and I'm kinda confused by the types
I'm at my first experience with SableCC and grammar definition. I have the following
You guys know PyQuery ? I was wondering if there’s an equivalent for Ruby.
I want to install pyquery on windows. But i cant run setup.py install on
I'm working in Python with HTML that looks like this. I'm parsing with lxml,
These types come from the demos for FastCGI Dll Library (with SIGTERM handler) for
I'm using my own class for database queries, extending mysqli: class iDatabase extends mysqli

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.