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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:44:25+00:00 2026-05-26T09:44:25+00:00

Actually I’ve parsed a website using htmlparser and I would like to find a

  • 0

Actually I’ve parsed a website using htmlparser and I would like to find a specific value inside the parsed object, for example, a string “$199”, and keep tracking that element(by periodic parsing) to see the value is still “$199” or has changed.

And after some painful stupid searching using my eyes, I found the that string is located at somewhere like this:

price = handler.dom[3].children[3].children[3].children[5].children[1].
        children[3].children[3].children[5].children[0].children[0].raw;

So I’d like to know whether there are methods which are less painful? Thanks!

  • 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-26T09:44:26+00:00Added an answer on May 26, 2026 at 9:44 am

    A tree based recursive search would probably be easiest to get the node you’re interested in.

    I’ve not used htmlparser and the documentation seems a little thin, so this is just an example to get you started and is not tested:

    function getElement(el,val) {
        if (el.children && el.children.length > 0) {
            for (var i = 0, l = el.children.length; i<l; i++) {
                var r = getElement(el.children[i],val);
                if (r) return r;
            }
        } else {
            if (el.raw == val) {
                return el;
            }
        }
        return null;
    }
    

    Call getElement(handler.dom[3],'$199') and it’ll go through all the children recursively until it finds an element without an children and then compares it’s raw value with ‘$199’. Note this is a straight comparison, you might want to swap this for a regexp or similar?

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

Sidebar

Related Questions

Actually, I would like to have some kind of progress bar. I would like
Actually, I'm using this way. Do you have a better way? private bool AcceptJson(HttpRequest
Actually here is a similar topic with little practical value. As far as I
Actually what i am trying to build is like a kind of firewall. It
Actually i have a little brain bender and and just can't find the right
Actually I don't know how to find solution to this problem and how to
Actually, my question is why we are using configs.ini file in PHP?, What is
actually I can not find an exact title for this problem. But I can
Actually I'm always using Generic Collections and I frequently use List<>. Some scenarios I
actually I'm have a very simple problem (that's for sure) I just can't find

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.