Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#ASP.NET
Hi all,
 
Scenario:
I have a windows application with a Web Browser control in it.
There are hundreds of links in that web page, each linking to different documents.
On the click of every link, the document loads in the same webpage.
 
Now here is the question:
Is there a way so that after the web page is loaded completely, each of the link click event in the page is raised and hence the corresponding documents (which is nothing but 'href' of the links) are saved in a specified location in the computer.
[either through threading or else one after another]
 
Below is a little progress from my side.
 
protected void doc_completed(object sender, WebBrowserDocumentCompletedEventArgs e)
       {          
           HtmlElementCollection mylinks = mywebBrowser.Document.GetElementsByTagName("A");
           
Posted 29-Sep-12 10:59am
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I used the asyn file download function to download all the files that were linked in the web page.
 

foreach(HtmlElement single_link in mylinks)
{
 WebClient client = new WebClient();
 client.DownloadFileAsync(new Uri("SomeURLToFile"),"SomePlaceOnLocalHardDrive");
}
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

You can always use Html Agility Pack.
 
HtmlWeb hw = new HtmlWeb();
 HtmlDocument doc = hw.Load(/* url */);
 foreach(HtmlNode link in doc.DocumentElement.SelectNodes("//a[@href]"))
 {
 
 }
 
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Guruprasad.K.Basavaraju 444
1 Sergey Alexandrovich Kryukov 360
2 Shai Vashdi 318
3 OriginalGriff 265
4 Peter Leow 181
0 Sergey Alexandrovich Kryukov 9,169
1 OriginalGriff 5,290
2 Peter Leow 4,020
3 Maciej Los 3,535
4 Abhinav S 3,263


Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 1 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid