![]() |
|
how to make it work automatically ? - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Visual Basic & .NET Framework (https://sinister.ly/Forum-Visual-Basic-NET-Framework) +--- Thread: how to make it work automatically ? (/Thread-how-to-make-it-work-automatically) |
RE: how to make it work automatically ? - blowdoof - 07-22-2011 ok, try this... Code: 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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
parameter = ComboBox1.Text
BackgroundWorker1.RunWorkerAsync(parameter)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If (ListBox1.SelectedIndex <> -1) Then _
Process.Start(ListBox1.SelectedItem.ToString())
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
WebBrowser1.Navigate(ComboBox1.Text)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Focus()
SendKeys.Send("^f")
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 * 100)
BackgroundWorker1.ReportProgress(i)
End Sub
Private Sub pageIsChecked() Handles Me.PageChecked
If i < 4 Then
i += 1
BackgroundWorker1.RunWorkerAsync(parameter)
Else
'sort & remove the duplicates...
End If
End Sub
Private Sub ZoomToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZoomToolStripMenuItem.Click
WebBrowser1.Document.ForeColor = Color.Chocolate
End SubRE: how to make it work automatically ? - blowdoof - 07-22-2011 ok, try this... Code: 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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
parameter = ComboBox1.Text
BackgroundWorker1.RunWorkerAsync(parameter)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If (ListBox1.SelectedIndex <> -1) Then _
Process.Start(ListBox1.SelectedItem.ToString())
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
ListBox1.Items.Clear()
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then
WebBrowser1.Navigate(ComboBox1.Text)
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
WebBrowser1.Focus()
SendKeys.Send("^f")
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 * 100)
BackgroundWorker1.ReportProgress(i)
End Sub
Private Sub pageIsChecked() Handles Me.PageChecked
If i < 4 Then
i += 1
BackgroundWorker1.RunWorkerAsync(parameter)
Else
'sort & remove the duplicates...
End If
End Sub
Private Sub ZoomToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ZoomToolStripMenuItem.Click
WebBrowser1.Document.ForeColor = Color.Chocolate
End SubRE: how to make it work automatically ? - polas - 07-22-2011 Bravo :thumbs: Good job. Here is the result. ![]() RE: how to make it work automatically ? - polas - 07-22-2011 Bravo :thumbs: Good job. Here is the result. ![]() RE: how to make it work automatically ? - polas - 07-22-2011 I think this is better if you wana make it the with any windows theme your application like mine. You need to download skinsoft visualstyler like that and applay your skin from windows msstyle.dll ![]() This the best and easy way. Just for you my friends ![]() Have fun. This is clean. skinsoft visualstyler lz0 Here is now it looks like my program. ![]() RE: how to make it work automatically ? - polas - 07-22-2011 I think this is better if you wana make it the with any windows theme your application like mine. You need to download skinsoft visualstyler like that and applay your skin from windows msstyle.dll ![]() This the best and easy way. Just for you my friends ![]() Have fun. This is clean. skinsoft visualstyler lz0 Here is now it looks like my program. ![]() RE: how to make it work automatically ? - polas - 07-22-2011 Ok i this is good that you help me to make it work correctly but there one problem in your code now i checked 20 times and some it will go to 8 number sometimes goes up to 2 number of google results. And you know what's the problem in your code is that it extract not those links here. Example i choose vb.net programming tutorials it show not those links just i type in combobox text field it go and extract but not those links ![]() So think this is done some where mistake in codes. Sorry but i need more suggestion. I'm really very helpfull for your help to me but i need to fix this and without your help i won't do it. The problem with your code that i do not like repeating links This is with your code problem when typed the same keywords and onther problem when i enter any keywords it will not look for i need just random give me links ![]() Look at the google keyword and links results in this picture and you will see that's wrong llinks and not those keywords at all ![]() And This is without your code when typed the same keywords but manully and got correct sites,links and keywords. So where is the problem the code works but show not those links and give not those keywords. And Look at the google keywords and links results in this picture and you will see that's correct sites,links and keywords. ![]() so where is the problem. Maybe I understand you are already tired of me, but your help would be really valuable. RE: how to make it work automatically ? - polas - 07-22-2011 Ok i this is good that you help me to make it work correctly but there one problem in your code now i checked 20 times and some it will go to 8 number sometimes goes up to 2 number of google results. And you know what's the problem in your code is that it extract not those links here. Example i choose vb.net programming tutorials it show not those links just i type in combobox text field it go and extract but not those links ![]() So think this is done some where mistake in codes. Sorry but i need more suggestion. I'm really very helpfull for your help to me but i need to fix this and without your help i won't do it. The problem with your code that i do not like repeating links This is with your code problem when typed the same keywords and onther problem when i enter any keywords it will not look for i need just random give me links ![]() Look at the google keyword and links results in this picture and you will see that's wrong llinks and not those keywords at all ![]() And This is without your code when typed the same keywords but manully and got correct sites,links and keywords. So where is the problem the code works but show not those links and give not those keywords. And Look at the google keywords and links results in this picture and you will see that's correct sites,links and keywords. ![]() so where is the problem. Maybe I understand you are already tired of me, but your help would be really valuable. RE: how to make it work automatically ? - blowdoof - 07-23-2011 Polas, all the code does is load the google page with the given keyword, showing 100 results / page... once loaded, it fetches all the urls and copies them to the listbox...then it auto moves on to the next page... Keep in mind that google may automatically stop at a certain page (f.e. 2nd page) if it thinks that the rest of the results are 'similar' to the previous results... that's what might be causing it to stop at page 2... I did several tests myself here and all of them worked perfect. What has been left out of the given code, is the removal of duplicates (which isn't a hard deal, see the reserved place in the code where to put that routine) RE: how to make it work automatically ? - polas - 07-23-2011 Thank you my friends. Anyway,you're cool ![]() I want to ask it is possible to extract urls from treeview or datagridview ? If so. So how to do this using webbrowser1.document_completed Or maybe there is another way to make it i tried to make it in listview for fun and it works great ![]() But i saw that it can be extracted in datagridview. Example: I want to make it work in for each i as blabla and so on. I would like to see how it can be extracted using datagridview. I know that's possible to do this. But i do not how. Or simple question how to make listbox clickable for text and open links from listbox ? Thanks in advance. to understand better what i want look at picture. See in the picture in listbox keywords ? ![]() So I need to make this text clickable and open in webbrowser. I know that links can do that but with text it is possible to do this ? Here is the code for lickable links. Code: Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
If (ListBox1.SelectedIndex <> -1) Then _
Process.Start(ListBox1.SelectedItem.ToString())
End SubMaybe you can help me to change somthing in this code to make a text clickable for browser ? |