从网页返回值到文本框

时间:2016-11-21 15:15:19

标签: html vb.net web-scraping

Rbx.trade/s/是一个可以查找用户的网站。我遍历一个用户列表,一次只在搜索框中放置一个用户名。现在我的程序启动一个新的浏览器来查看用户统计信息。我想在没有打开浏览器的情况下在我的程序中显示他们的统计数据。我试图将页面读成字符串但我的信息没有列出。  我想在textbox4中显示RAP值。我该怎么做?

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

这会返回一些文字,但不会返回我寻找的值

0 个答案:

没有答案
相关问题