VS 2017 Grab multiple text from a web-pages source-VBForums
Results 1 to 1 of 1

Thread: Grab multiple text from a web-pages source

  1. #1

    Thread Starter
    Addicted Member sinner0636's Avatar
    Join Date
    Sep 2009

    Grab multiple text from a web-pages source

    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

    Imports System.Net
    Public HTMLString As String
     Public Function NthField(ByVal expression As String, ByVal separator As String, ByVal fieldNum As Long) As String
                Dim fields() As String
                fields = Split(expression, separator, , vbTextCompare)
                Return fields(CInt(fieldNum - 1))
            Catch ex As Exception
            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


    i get all the links to the text just need the text to go with the links

     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
                    End If
                End If
    Last edited by sinner0636; Feb 23rd, 2018 at 08:45 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts


Click Here to Expand Forum to Full Width