Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Screen scraping in C# using HtmlAgilityPack.
WhatsApp
tarequl islam
14y
16.6
k
0
0
25
Blog
In my project, i have used
HtmlAgilityPack
library to capture the page and parse it.
1. First you create a asp.net project and add
HtmlAgilityPack
reference in your project.
2. Create a 'HtmlWeb' object
3. Load the html page using 'HtmlDocument'
4. now you get html page in 'HtmlDocument' object.
5. You can display this 'HtmlDocument' object in asp 'Literal' control.
the code this below
HtmlWeb hwObject = new HtmlWeb();
HtmlDocument htmldocObject = hwObject.Load("http://www.c-sharpcorner.com");
lLatestPrice.Text = htmldocObject.DocumentNode.InnerHtml;
You can find all link from this page using a loop like this
foreach (HtmlNode link in htmldocObject.DocumentNode.SelectNodes("//a[@href]"))
{
string s = link.InnerText;
}
thats it.....
Up Next
Get the processor id using c#
Ebook Download
View all
Printing in C# Made Easy
Read by 22.4k people
Download Now!
Learn
View all
Membership not found