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

  • Home
  • SEARCH
  • 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 6015705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:52:29+00:00 2026-05-23T02:52:29+00:00

I am attempting to use the HTML Agility Pack to look up specific keywords

  • 0

I am attempting to use the HTML Agility Pack to look up specific keywords on Google, then check through linked nodes until it find my websites string url, then parse the innerHTML of the node I am on for my Google ranking.

I am relatively new to the Agility Pack (as in, I started really looking through it yesterday) so I was hoping I could get some help on it. When I do the search below, I get Failures on my Xpath queries every time. Even if I insert something as simple as SelectNodes(“//*[@id=’rso’]”). Is this something I am doing incorrectly?

    private void GoogleScrape(string url)
    {
        string[] keys = keywordBox.Text.Split(',');
        for (int i = 0; i < keys.Count(); i++)
        {
            var raw = "http://www.google.com/search?num=100&q=";
            string search = raw + HttpUtility.UrlEncode(keys[i]);
            var webGet = new HtmlWeb();
            var document = webGet.Load(search);
            loadtimeBox.Text = webGet.RequestDuration.ToString();

            var ranking = document.DocumentNode.SelectNodes("//*[@id='rso']");

            if (ranking != null)
            {
                googleBox.Text = "Something";
            }
            else
            {
                googleBox.Text = "Fail";
            }
           }
          }
  • 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-23T02:52:29+00:00Added an answer on May 23, 2026 at 2:52 am

    It’s not the Agility pack’s guilt — it is tricky google’s. If you inspect _text property of HtmlDocument with debugger, you’ll find that <ol> that has id='rso' when you inspect it in a browser do not have any attributes for some reason.

    I think, in this case you can just serach by “//ol”, because there is only one <ol> tag in the google’s result page at the moment…

    UPDATE: I’ve done further checks. For example when I do this:

    using (StreamReader sr = 
            new StreamReader(HttpWebRequest
              .Create("http://www.google.com/search?num=100&q=test")
              .GetResponse()
              .GetResponseStream()))
    {
        string s = sr.ReadToEnd();
        var m2 = Regex.Matches(s, "\\sid=('[^']+'|\"[^\"]+\")");
        foreach (var x in m2)
            Console.WriteLine(x);
    }
    

    The only ids that are returned are: “sflas”, “hidden_modes” and “tbpr_12”.

    To conclude: I’ve used Html Agility Pack and it’s coped pretty well even with malformed html (unclosed <p> and even <li> tags etc.).

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

Sidebar

Related Questions

I am attempting to use the Agility pack to parse certain bits of info
I'm attempting to use fluent html and the spark view engine in my asp.net
I'm attempting to use jsoup to sanitize the the html posted from a wysiwyg
I'm attempting to use mod_rewrite to redirect requests to 123.example.com/456/file.html to example.com/123/456/file.html . The
I'm attempting to use boost::format, where my formatting string is the HTML below. I
I am attempting to use BeautifulSoup to parse through a DOM tree and extract
I'm attempting to create an html element as a jQuery object, and then reference
I am attempting to use the google visualization library - intensity map. I have
Android 3.2. Attempting to use Switch (http://developer.android.com/reference/android/widget/Switch.html) in my project. Switch.class is not found
I am attempting to use the HtmlAgilityPack library to parse some links in a

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.