Automatically pick urls in listbox then load to webbrowser

Posts 18 of 8 · Page 1 of 1
Automatically pick urls in listbox then load to webbrowser
I found the best solution to make this program.
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 urls automatically from all pages like 1,2,3,4,5,6,7,8,9 next.
now it does only 1 page.

Here is the part of my code in which i want to make it work and another.

Code:
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 using timer,multi threading,backgroundworker for loop, for i = 0 to,do untill or do while i'm new ?

Or maybe you can just help me to fix this code.


This is what i want.


I have the code which is doing automatically but i need your help.
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 random sites and links.
can you help me fix it ?

Here is the code for far to go:
I can't find how to fix it on internet
I want to make it go with pause 5 seconds and go to next page and so on.

Code:
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****/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
Just change &start=X parameter.

For i = 0 to 80 Step 10 'page 1-9
'retreive links here
Next
Hangs on the first page and get the same where to put it exactly like this i did or where ?

Code:
 For ii = 0 To 80 Step 10 'page 1-9
            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
        Next

 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****/search?num=100&q=" & path & "&start=X" & i * 200)
        BackgroundWorker1.ReportProgress(i)
    End Sub
Try to actually use your brain before attempting to randomly copy & paste stuff.
How can say think your brain if i'm new for vb.net just for 2 weeks.
As i know as i know and this is all i know for so far.
so can you help ?

I just know that exits a lot of codes of vb.net i do no know a lot of them and where exatcly put them
Now do you undersntand.
Quote Originally Posted by polas6 View Post
How can say think your brain if i'm new for vb.net just for 2 weeks.
As i know as i know and this is all i know for so far.
so can you help ?

I just know that exits a lot of codes of vb.net i do no know a lot of them and where exatcly put them
Now do you undersntand.
Google Translate

Use it ^

Please?
(If not, then I don't know how you expect to make yourself understandable to anyone who wishes to help you.)
You gave me the code but can't explain where to put it in backgroundworker or documentcompleted as i put.

And now you say use google translate.
It is a nonsense to use google translate.
Because it translates everything in reverse, and most obscure.
Beto what I need it I will not understand what you are to me filamentary if it ask for help with vb.net and not a translation.
Is it so hard to help?

I gave the codes.
and i do not understand you.
all codes in there just need some change and you can't help is it hard or what ?
I just told you i'm novice for that.
So maybe now you will help me.
And more i'm not an english man.

Thank you in advance.
Quote Originally Posted by polas6 View Post
You gave me the code but can't explain where to put it in backgroundworker or documentcompleted as i put.

And now you say use google translate.
It is a nonsense to use google translate.
Because it translates everything in reverse, and most obscure.
Beto what I need it I will not understand what you are to me filamentary if it ask for help with vb.net and not a translation.
Is it so hard to help?

I gave the codes.
and i do not understand you.
all codes in there just need some change and you can't help is it hard or what ?
I just told you i'm novice for that.
So maybe now you will help me.
And more i'm not an english man.

Thank you in advance.
The answer was given to you in the first reply, and if you can't adapt that answer to your code then I don't see why we should write the code for you so you can simply copy and paste it. You need to learn how to do these kinds of things.

And the reason why I told you to use Google translate is because no one would have understand sh-- of what you asked. If you want help I highly advice you make yourself understandable instead of just typing what seems right to you. Google translate isn't a sin too use, I myself use it all the time for words I don't quite understand or words I don't know the exact spelling of.

So once again, read the first reply given to you and don't ask for the code itself, you want to make the program not us.
Posts 18 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?