QuestionNeed Help With A Program Using Search In A Site

Posts 14 of 4 · Page 1 of 1
Need Help With A Program Using Search In A Site
I want to make a program that i specify the ip and ports and when i search i get the results back, from this site: ipfingerprints.com/portscan.php


I made the code for the button but i can't seem to make it work.
Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
    Try
        For Each elem1 As HtmlElement In WebBrowser2.document.GetElementsByTagName("Scan")
            WebBrowser2.document.GetElementById("remoteHost").SetAttribute("value", TextBox5.Text)
            WebBrowser2.document.GetElementById("start_port").SetAttribute("value", TextBox6.Text)
            WebBrowser2.document.GetElementById("end_port").SetAttribute("value", TextBox7.Text)
            If elem1.GetAttribute("className") = "input-button" Then
                elem1.InvokeMember("click")
            End If
        Next
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
Any help would be appreciated!
Run a test for me..

Code:
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

Dim itemCount as Integer = 0
    
    Try
        For Each elem1 As HtmlElement In WebBrowser2.document.GetElementsByTagName("Scan")
          itemCount +=1  
        Next

    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try

    MessageBox.Show("Item Count: " & itemCount.ToString())
End Sub
How many items is it finding by the tag name "Scan"? If 0, then any code inside your FOREACH loop isn't getting run.

---------------------------------------------------------
Code:
    For Each elem1 As HtmlElement In WebBrowser2.document.GetElementsByTagName("Scan")
            WebBrowser2.document.GetElementById("remoteHost").SetAttribute("value", TextBox5.Text)
            WebBrowser2.document.GetElementById("start_port").SetAttribute("value", TextBox6.Text)
            WebBrowser2.document.GetElementById("end_port").SetAttribute("value", TextBox7.Text)
And surely you don't want that running inside a loop? No reason to set the attribute multiple times.
GetElementById() is good, but doesn't need to be inside a loop.
Sorry for the late reply, but my code was correct. I just had some values and class names wrong, thats all. My code, doesn't loop. It works fine.
Thanks, again for the help anyway.
Edit: The results come back in the browser and then i save the result class from the site in a txt file.
Glad it's working.

For Each IS a loop.
Posts 14 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

Need help?