Private Sub WebBrowser1_DocumentCompleted (ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
If (WebBrowser1.ReadyState WebBrowserReadyState.Complete =) Then
For Each ClientControl I HtmlElement In WebBrowser1.Document.Links
IF NOT ClientControl.GetAttribute ("href"). Contains (Google) And ClientControl.GetAttribute ("href"). Contains ("http") and ClientControl.GetAttribute ("href"). Contains ("http") Then
ListBox1.Items.Add (ClientControl.GetAttribute ('href'))
end If
Next
end If
end Sub
Private Sub Button1_Click (ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate (http://www.google****/search?num=100&q = "& ComboBox1.Text)
BackgroundWorker1.RunWorkerAsync ()
end Sub
Private Sub BackgroundWorker1_DoWork (ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
For i = 0 to 100
Threading.Thread.Sleep (200)
BackgroundWorker1.ReportProgress (i)
Next
end Sub
Private Sub BackgroundWorker1_ProgressChanged (ByVal sender As Object, ByVal e As System.ComponentModel.ProgressChangedEventArgs) Handles BackgroundWorker1.ProgressChanged
Label1.Text = e.ProgressPercentage
end Sub




Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Function GetGoogleResults(ByVal searchString As String, ByVal pageNumber As String) As List(Of String)
Dim lstLinks As New List(Of String)
Dim pgSource As String = String.Empty
Using wc As New Net.WebClient
pgSource = wc.DownloadString("http://www.google.com/search?q=" & searchString & "&start=" & ((pageNumber - 1) * 10))
End Using
Dim hrefRegex As New Regex("href=""[^""]+")
Dim googleRegex As New Regex("http://[^\.]+.google(usercontent)*.com/.*")
For Each m As Match In hrefRegex.Matches(pgSource)
Dim sLink As String = m.Value.Split(""""c)(1)
If googleRegex.IsMatch(sLink) Or Not sLink.StartsWith("http://") Then Continue For
lstLinks.Add(sLink)
Next
Return lstLinks
End Function
Dim oldSearchResults As New List(Of String)
Private Sub DoStuffs()
Dim bLinksAreSame As Boolean = False
Dim currentPage As Integer = 1
While Not bLinksAreSame
Dim lstGoogleLinks As List(Of String) = GetGoogleResults("blah", currentPage)
If lstGoogleLinks.Count = oldSearchResults.Count Then
For i As Integer = 0 To lstGoogleLinks.Count - 1
If lstGoogleLinks(i) <> oldSearchResults(i) Then Exit For
If i = oldSearchResults.Count - 1 Then bLinksAreSame = True
If bLinksAreSame Then Exit For
Next
End If
If bLinksAreSame Then Exit While
For Each link In lstGoogleLinks
ListBox1.Items.Clear()
ListBox1.BackColor = Color.Black
ListBox1.ForeColor = Color.WhiteSmoke
Me.Text = "Working..."
Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com" + TextBox1.Text)
Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search(TextBox1.Text, 100, "English", "Off")
For Each item As Google.API.Search.IWebResult In results
ListBox1.Items.Add(item.Url)
ListBox1.Items.Add(item.Title)
ListBox1.Items.Add(vbNewLine)
Next
Next
oldSearchResults = lstGoogleLinks
currentPage += 1
End While
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(GetGoogleResults("what em i doing wrong ?", 1))
End Sub


Imports System.Text.RegularExpressions
Public Class Form1
Private Function GetGoogleResults(ByVal searchString As String, ByVal pageNumber As String) As List(Of String)
Dim lstLinks As New List(Of String)
Dim pgSource As String = String.Empty
Using wc As New Net.WebClient
pgSource = wc.DownloadString("http://www.google.com/search?q=" & searchString & "&start=" & ((pageNumber - 1) * 10))
End Using
Dim hrefRegex As New Regex("href=""[^""]+")
Dim googleRegex As New Regex("http://[^\.]+.google(usercontent)*.com/.*")
For Each m As Match In hrefRegex.Matches(pgSource)
Dim sLink As String = m.Value.Split(""""c)(1)
If googleRegex.IsMatch(sLink) Or Not sLink.StartsWith("http://") Then Continue For
lstLinks.Add(sLink)
Next
Return lstLinks
End Function
Dim oldSearchResults As New List(Of String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim bLinksAreSame As Boolean = False
Dim currentPage As Integer = 1
While Not bLinksAreSame
Dim lstGoogleLinks As List(Of String) = GetGoogleResults("blah", currentPage)
If lstGoogleLinks.Count = oldSearchResults.Count Then
For i As Integer = 0 To lstGoogleLinks.Count - 1
If lstGoogleLinks(i) <> oldSearchResults(i) Then Exit For
If i = oldSearchResults.Count - 1 Then bLinksAreSame = True
If bLinksAreSame Then Exit For
Next
End If
If bLinksAreSame Then Exit While
For Each link In lstGoogleLinks
ListBox1.Items.Clear()
ListBox1.BackColor = Color.Black
ListBox1.ForeColor = Color.WhiteSmoke
Me.Text = "Working..."
Dim gwebsearcher As New Google.API.Search.GwebSearchClient("http://www.google.com" + TextBox1.Text)
Dim results As IList(Of Google.API.Search.IWebResult) = gwebsearcher.Search(TextBox1.Text, 100, "English", "Off")
For Each item As Google.API.Search.IWebResult In results
ListBox1.Items.Add(item.Url)
ListBox1.Items.Add(item.Title)
ListBox1.Items.Add(vbNewLine)
Next
Next
oldSearchResults = lstGoogleLinks
currentPage += 1
End While
End Sub