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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:41:35+00:00 2026-06-17T16:41:35+00:00

Task I’m supposed to create an application that extracts the name of an item

  • 0

Task

I’m supposed to create an application that extracts the name of an item from an Amazon.com webpage.

Action

I thought I would used the Html Agility Pack to get this done, and I think I’ve got a solution going, but there is one bug that keeps persisting.

Result

Lets say I have tried to pull the html source from n different sites, the application always uses the source of the first site for sites 1 – n and I’m not sure why. I can extract html from a different website if and only if I restart my computer.

Code

    private void extractHTML()
    {
        //retreive URL
        string address = txtURL.Text;
        string itemId = "result_0";

        //create document
        HtmlWeb webGet = new HtmlAgilityPack.HtmlWeb();
        HtmlAgilityPack.HtmlDocument document = webGet.Load(address);

        //look for name of result
        HtmlNode node = document.GetElementbyId(itemId);            
        if(node != null)
        {
            IEnumerable<HtmlNode> allH3 = node.Descendants("h3");

            foreach (HtmlNode h3 in allH3)
            {
                if (h3.ChildNodes[1].InnerHtml == null)
                {
                    continue;
                }
                else
                {
                    lblId.Text = itemId;

                    //dig down to lowest subnode to get correct InnerHtml
                    HtmlNode subNode = h3.ChildNodes[1];
                    if (subNode.ChildNodes.Count > 0)
                    {
                        lblName.Text = subNode.ChildNodes[subNode.ChildNodes.Count - 1].InnerHtml;
                        break;
                    }
                    else
                    {
                        lblName.Text = h3.ChildNodes[1].InnerHtml;                            
                        break;
                    }
                }
            }
        }            
    }

Help is much appreciated! Thanks in advance.

  • 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-17T16:41:35+00:00Added an answer on June 17, 2026 at 4:41 pm

    If, as stated in the comments, you’re targeting a page such as http://www.amazon.com/s/ref=nb_sb_ss_i_0_5?url=search-alias%3Daps&field-keywords=radio&sprefix=radio%2Caps%2C182 to try to get all item names, then the following code:

    HtmlDocument doc = new HtmlDocument();
    doc.Load(myHtmlFile);
    
    foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//span[@class='lrg bold']"))
    {
        Console.WriteLine(node.InnerHtml);
    }
    

    will output this:

    Sony ICF-S10MK2 Pocket AM/FM Radio, Silver
    Ambient Weather WR-111A Emergency Solar Hand Crank AM/FM/NOAA Digital Radio, Flashlight, Cell Phone Charger with NOAA Certified Weather Alert &amp; Cables
    Sony ICF38 Portable AM/FM Radio (Black)
    Coby CX39 World Band AM/FM/Shortwave Radio with Digital Display, Silver
    Radio
    Sony ICF-C318 Clock Radio with Dual Alarm (Black)
    Sony Icf38 Portable Am Fm Radio Led Tuning Indicator Lg Spkr
    TuneIn Radio
    Sangean WR-2 Digital AM/FM Tabletop Radio, Walnut
    SANGEAN WR-11 AM/FM Table Top Radio
    Crosley Solo Radio CR221 Black
    Sony ICF-C218 Automatic Time Set Clock Radio (Black)
    Coby CXCD251BLK Portable CD Player with AM/FM Radio, Black
    Sony ICFC414 Clock Radio
    Radio
    Panasonic RF-P50 Pocket AM/FM Radio, Silver
    

    The XPATH expression will just get all SPAN elements that have a CLASS attribute set to ‘lrg bold’. To find that, I just looked at the saved version of the HTML and determined a good discriminant for the item names.

    I suggest you learn a bit of XPATH, as it’s very powerful. A good tutorial is here: XPATH Tutorial

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

Sidebar

Related Questions

My task is to retrieve an xml from https://test24.highrisehq.com/tasks/upcoming.xml that is a secure connection
Task is following: how to create selected picture mosaic from large number of images.
Task: During the process of action of Zend Application to achieve next: - for
My task is to create an ASP.NET application with a piece of code which
Task: I wanted to create a simple share button which extends to a share
Task is to execute bash script from python script and let it execute on
Task Manager says that IE is using over 500MB of private working set. Both
Task: Write timestamps into MS SQL database table every second. Solutions: External application which
Task: To delete records in db using ajax from a link in the table
task_payments SELECT t.id AS task_id, t.name, t.created_at ,COALESCE(SUM(tp1.amount),0) AS paid ,COALESCE(SUM(tp2.amount),0) AS paid_back FROM

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.