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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:08:36+00:00 2026-05-25T19:08:36+00:00

I want to scrape a Wiki page. Specifically, this one. My app will allow

  • 0

I want to scrape a Wiki page. Specifically, this one.

My app will allow users to enter the registration number of the vehicle (for example, SBS8988Z) and it will display the related information (which is on the page itself).

For example, if the user enters SBS8988Z into a text field in my application, it should look for the line on that wiki page

SBS8988Z (SLBP 192/194*) - F&N NutriSoy Fresh Milk: Singapore's No. 1 Soya Milk! (2nd Gen)

and return SBS8988Z (SLBP 192/194*) – F&N NutriSoy Fresh Milk: Singapore’s No. 1 Soya Milk! (2nd Gen).

My code so far is (copied and edited from various websites)…

WebClient getdeployment = new WebClient();
string url = "http://sgwiki.com/wiki/Scania_K230UB_(Batch_1_Euro_V)";

getdeployment.Headers["User-Agent"] = "NextBusApp/GetBusData UserAgent";
string sgwikiresult = getdeployment.DownloadString(url); // <<< EXCEPTION
MessageBox.Show(sgwikiresult); //for debugging only!

HtmlAgilityPack.HtmlDocument sgwikihtml = new HtmlAgilityPack.HtmlDocument();
sgwikihtml.Load(new StreamReader(sgwikiresult));
HtmlNode root = sgwikihtml.DocumentNode;

List<string> anchorTags = new List<string>();   

foreach(HtmlNode deployment in root.SelectNodes("SBS8988Z"))
{
    string att = deployment.OuterHtml;
    anchorTags.Add(att);
}

However, I am getting a an ArgumentException was unhandled – Illegal Characters in path.

What is wrong with the code? Is there an easier way to do this? I’m using HtmlAgilityPack but if there is a better solution, I’d be glad to comply.

  • 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-25T19:08:36+00:00Added an answer on May 25, 2026 at 7:08 pm

    What’s wrong with the code? To be blunt, everything. 😛

    The page is not formatted in the way you are reading it. You can’t hope to get the desired contents that way.

    The contents of the page (the part we’re interested in) looks something like this:

    <h2>
    <span id="Deployments" class="mw-headline">Deployments</span>
    </h2>
    <p>
        <!-- ... -->
        <b>SBS8987B</b>
        (SLBP 192/194*)
        <br>
        <b>SBS8988Z</b>
        (SLBP 192/194*) - F&amp;N NutriSoy Fresh Milk: Singapore's No. 1 Soya Milk! (2nd Gen)
        <br>
        <b>SBS8989X</b>
        (SLBP SP)
        <br>
        <!-- ... -->
    </p>
    

    Basically we need to find the b elements that contain the registration number we are looking for. Once we find that element, get the text and put it together to form the result. Here it is in code:

    static string GetVehicleInfo(string reg)
    {
        var url = "http://sgwiki.com/wiki/Scania_K230UB_%28Batch_1_Euro_V%29";
    
        // HtmlWeb is a helper class to get pages from the web
        var web = new HtmlAgilityPack.HtmlWeb();
    
        // Create an HtmlDocument from the contents found at given url
        var doc = web.Load(url);
    
        // Create an XPath to find the `b` elements which contain the registration numbers
        var xpath = "//h2[span/@id='Deployments']" // find the `h2` element that has a span with the id, 'Deployments' (the header)
                  + "/following-sibling::p[1]"     // move to the first `p` element (where the actual content is in) after the header
                  + "/b";                          // select the `b` elements
    
        // Get the elements from the specified XPath
        var deployments = doc.DocumentNode.SelectNodes(xpath);
    
        // Create a LINQ query to find the  requested registration number and generate a result
        var query =
            from b in deployments                 // from the list of registration numbers
            where b.InnerText == reg              // find the registration we're looking for
            select reg + b.NextSibling.InnerText; // and create the result combining the registration number with the description (the text following the `b` element)
    
        // The query should yield exactly one result (or we have a problem) or none (null)
        var content = query.SingleOrDefault();
    
        // Decode the content (to convert stuff like "&amp;" to "&")
        var decoded = System.Net.WebUtility.HtmlDecode(content);
    
        return decoded;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use greasemonkey to scrape wiki data from Last.fm (this is not
I want to scrape this web page using Mechanize. The form element looks like
I want to scrape a list of facts from simple website. Each one of
I want to scrape this URL : https://www.xstreetsl.com/modules.php?searchSubmitImage_x=0&searchSubmitImage_y=0&SearchLocale=0&name=Marketplace&SearchKeyword=business&searchSubmitImage.x=0&searchSubmitImage.y=0&SearchLocale=0&SearchPriceMin=&SearchPriceMax=&SearchRatingMin=&SearchRatingMax=&sort=&dir=asc Go into each of the links
I want to scrape a website page and then save some of the information
A WinForm application. I want to scrape a part of an HTML web page
I've just started looking into this, I want to scrape my Netgear Router (
I want to scrape data from a page which loads DOM elements using Ajax
I want to scrape the the number of players from each playlist, just the
Can this be done if so, how? I want to scrape data from xbox.com

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.