TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Screen scraping in C# using HtmlAgilityPack.
tarequl islam
Apr 26, 2010
16.5
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In my example, you can scraping complete page or a part of page.
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.....
Next Recommended Reading
Get the processor id using c#