0
     Dim url As New Uri("http://www.testpage.com")
    If url.Scheme = Uri.UriSchemeHttp Then
        'Create Request Object
        Dim objRequest As HttpWebRequest = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)
        'Set Request Method
        objRequest.Method = WebRequestMethods.Http.[Get]
        'Get response from requested url
        Dim objResponse As HttpWebResponse = DirectCast(objRequest.GetResponse(), HttpWebResponse)
        'Read response in stream reader
        Dim reader As New StreamReader(objResponse.GetResponseStream())
        Dim tmp As String = reader.ReadToEnd()
        objResponse.Close()
        'Set response data to container
        Label1.Text = tmp
    End If

How Would I only scrape part of a webpage..The code succesfulyl get the full html content.

For Example..I want to scrape eveyrthing between <div id="content"> </div>

4

1 回答 1

1

在字符串变量中拥有页面的完整 html 内容后,您可以在此字符串上使用正则表达式来返回要提取的部分。

由于您尚未提供有关要提取的内容的详细信息,因此我将为您提供有关如何使用正则表达式的链接。

可以在此处找到有关正则表达式的简短教程

于 2012-05-31T21:38:41.497 回答