hi
i have a question coded a code that gets the text from a webpages html source with a webbrowser i want to be able to search a webpages html source for the strings i need this code below grabs the first string but but would like it to be done with the webbrowser filter out the text i need
Code:
Imports System.Net
Public HTMLString As String
Public Function NthField(ByVal expression As String, ByVal separator As String, ByVal fieldNum As Long) As String
Try
Dim fields() As String
fields = Split(expression, separator, , vbTextCompare)
Return fields(CInt(fieldNum - 1))
Catch ex As Exception
'Err
End Try
End Function
Public Function GetHTMLText(SearchItem As String) As String
Using client = New WebClient()
Dim pagehtml As String = client.DownloadString("https://www.mywebpage.com/?chto=" + SearchItem)
HTMLString = NthField(NthField(NthField(pagehtml, "href=javascript:d", 2), ")>", 2), "</a></td><td>", 1)
Return HTMLString
End Using
End Function
search button should get all the lines of text at one time but only gets first line
Code:
ListView1.Items.Add(GetHTMLText(TextBox1.Text))
i get all the links to the text just need the text to go with the links
Code:
For Each Ele As HtmlElement In WebBrowser1.Document.GetElementsByTagName("a")
Dim s As String = Ele.GetAttribute("href")
If InStr(s, "java") > 0 Then
s = Replace("https://www.mywebpage.com/d.php?n=" + NthField(s, ":d(", 2), ")", Nothing)
Dim Id As String = NthField(s, "php?n=", 2)
If IsNumeric(Id) Then
ListView1.Items.Add(s)
End If
End If
Next