Re: Get all links from page
I don't know how to do this stuff ... But I do know how to get the HTML source code of webpage currently opened in web browser control ...
Code:
Text1.Text = WebBrowser1.Document.Body.InnerHtml
This might be used to fetch all the hyperlinks in the document. But I don't know how to use this:
Code:
WebBrowser1.Document.Body.Links
Re: Get all links from page
Hey dude, I just got the code for doing your step 1 of program.
Try to open your that webpage in WebBrowser control.
vb Code:
WebBrowser1.Navigate("http://www.google.com.pk")
Now, use the following code under any Button.Click event or else:
vb Code:
If (WebBrowser1.ReadyState = WebBrowserReadyState.Complete) Then
For Each ClientControl As HtmlElement In WebBrowser1.Document.Links
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
Next
End If
Now, ListBox1 contains all the hyper-links in webpage: i.e. in google.com.pk
Re: Get all links from page
thanks, works great.
How can i sort the links and only keep ones that contain "/article/" in them?
Re: Get all links from page
use regex class to filter link's href
Re: Get all links from page
i used
Code:
For x = 0 To lcount
addition = LinkGrabber.Items.Item(x)
If addition.ToString().Contains("/article/") Then
alist.Text.Insert(0, addition.ToString())
End If
Next
but I get some error about 90 not being compatible with 'index'