Polas5
Member
My problem i have almost made the program which gives urls from google and collect in listbox and sort found as i typed links and copy into richtextbox.
But i need to pick up all urls from google automatically from all pages.
Because now it does only 1 page.
Here is the part of my code in which i want to make it work.
So the question would be how i can make it work automatically with my code using timer,multi threading or backgroundworker ?
here is that i want.
what i have this code but it does not pick urls automatically.
I have the code which is doing automatically but i need your help i have alot of great codes.
Ok what it gives me ?
First the code works great but the problem with it is not pick urls which i want because it gives me not those sites and links.
It just does only random urls.
So maybe if a good programmers can you help me fix it ?
Here it is:
But i need to pick up all urls from google automatically from all pages.
Because now it does only 1 page.
Here is the part of my code in which i want to make it work.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
WebBrowser1.Navigate("http://www.google.co.zw/search?num=100&hl=en&lr=&biw=1152&bih=683&q=" & TextBox1.Text)
End Sub
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 As HtmlElement In WebBrowser1.Document.Links
If Not ClientControl.GetAttribute("href").Contains("google") And ClientControl.GetAttribute("href").Contains("http") Then
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
End If
Next
End If
End sub
So the question would be how i can make it work automatically with my code using timer,multi threading or backgroundworker ?
here is that i want.
what i have this code but it does not pick urls automatically.
I have the code which is doing automatically but i need your help i have alot of great codes.
Ok what it gives me ?
First the code works great but the problem with it is not pick urls which i want because it gives me not those sites and links.
It just does only random urls.
So maybe if a good programmers can you help me fix it ?
Here it is:
VB.NET:
Public Class Form1
Private Event PageChecked()
Private i As Integer = 1
Private parameter As String
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 As HtmlElement In WebBrowser1.Document.Links
Try
If Not ClientControl.GetAttribute("href").Contains("google") And ClientControl.GetAttribute("href").Contains("http") Then
ListBox1.Items.Add(ClientControl.GetAttribute("href"))
End If
Catch ex As Exception
End Try
Next
End If
RaiseEvent PageChecked()
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Dim path As String = DirectCast(e.Argument, String)
WebBrowser1.Navigate("http://www.google.lt/search?num=100&q=" & path & "&start=" & i * 200)
BackgroundWorker1.ReportProgress(i)
End Sub
Private Sub pageIsChecked() Handles Me.PageChecked
If i < 4 Then
i += 1
BackgroundWorker1.RunWorkerAsync(parameter)
Else
End If
End Sub
Last edited: