Extract data from a Web page using .NET

 here’s a sample code in C# using the .NET framework to extract data from a Wiki web page

using System;
using System.Net;
using HtmlAgilityPack;

namespace WikiPageExtractorExample
{
    class Program
    {
        static void Main(string[] args)
        {
            // Define the Wiki web page URL
            string url = "https://en.wikipedia.org/wiki/.NET_Framework";

            // Create a new instance of the HTML web client
            WebClient client = new WebClient();

            // Download the HTML content of the web page
            string html = client.DownloadString(url);

            // Create a new instance of the HTML document
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(html);

            // Extract the text from the main content of the web page
            HtmlNode mainContent = doc.DocumentNode.SelectSingleNode("//div[@id='mw-content-text']");
            string text = mainContent.InnerText;

            Console.WriteLine(text);
            Console.WriteLine("Data has been extracted from the Wiki web page.");
            Console.ReadLine();
        }
    }
}

In this example, the HtmlAgilityPack library is used to extract data from the Wiki web page. The WebClient class is used to create a new instance of the HTML web client, which is used to download the HTML content of the web page. The HtmlDocument class is used to create a new instance of the HTML document, which is used to load the HTML content. The SelectSingleNode method of the HtmlNode class is used to select the main content of the web page by its ID attribute. The InnerText property of the HtmlNode object is used to extract the text from the main content of the web page. Finally, the extracted text is printed to the console.

Pamai Tech
Turning ideas into Reality

Products

Office Add-in

Enterprise Solutions

Cloud Consulting

UI UX Design

Data Transformation

Services

FAQ's

Privacy Policy

Terms & Condition

Team

Contact Us

Company

About Us

Services

Features

Our Pricing

Latest News

© 2025 Pamai Tech