0

Rbx.trade/s/ is a site where you can look up a user. I iterate through a list of users placing one username in the search box at a time . Right now my program launches a new browser to see the users stats. I would like to show their stats in my program without opening a browser. Ive tried to read the page into a string but my info was not listed. I would like the RAP value displayed in textbox4. how do I do this?

Private Sub Scrape()

    Try

        Dim strURL As String = "http://rbx.trade/s/" + TextBox1.Text

        Dim strOutput As String = ""

        Dim wrResponse As WebResponse
        Dim wrRequest As WebRequest = HttpWebRequest.Create(strURL)

        TextBox5.Text = "Extracting..." & Environment.NewLine

        wrResponse = wrRequest.GetResponse()

        Using sr As New StreamReader(wrResponse.GetResponseStream())
            strOutput = sr.ReadToEnd()
            ' Close and clean up the StreamReader
            sr.Close()
        End Using
        TextBox5.Text = strOutput
        'Formatting Techniques
        ' Remove Doctype ( HTML 5 )
        strOutput = Regex.Replace(strOutput, "<!(.|\s)*?>", "")
        ' Remove HTML Tags
        strOutput = Regex.Replace(strOutput, "</?[a-z][a-z0-9]*[^<>]*>", "")
        ' Remove HTML Comments
        strOutput = Regex.Replace(strOutput, "<!--(.|\s)*?-->", "")
        ' Remove Script Tags
        strOutput = Regex.Replace(strOutput, "<script.*?</script>", "", RegexOptions.Singleline Or RegexOptions.IgnoreCase)
        ' Remove Stylesheets
        strOutput = Regex.Replace(strOutput, "<style.*?</style>", "", RegexOptions.Singleline Or RegexOptions.IgnoreCase)
        TextBox4.Text = (strOutput) 'write Formatted Output To Separate TB
    Catch ex As Exception
        Console.WriteLine(ex.Message, "Error")

    End Try

End Sub

Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
    Scrape() 'Scrape Text From URL
End Sub

This returns some text but not the value I seek

  • [**Why you shouldn't parse HTML using Regex.**](http://stackoverflow.com/a/1732454/3740093) – Visual Vincent Nov 21 '16 at 15:29
  • It was the only means I could get a result with. I still cant get the value to show in my textbox. Just some which I could share if it would help? – Bobby_Boner Nov 21 '16 at 21:10
  • _Removing everything else_ is highly inefficient and is probably the hardest method to use when it comes to extracting a value. The only good answer for this is: Use an HTML parser. – Visual Vincent Nov 21 '16 at 21:19
  • I see you've tried to use HtmlAgilityPack in your previous question. You should've stuck with that instead of moving to Regex. If you feel it's too advanced you can always try the [**built-in parser**](https://msdn.microsoft.com/en-us/library/system.windows.forms.htmldocument(v=vs.110).aspx). – Visual Vincent Nov 21 '16 at 21:29

0 Answers0