Imports System.Net
我們一直強調(diào)成都做網(wǎng)站、網(wǎng)站設計、外貿(mào)營銷網(wǎng)站建設對于企業(yè)的重要性,如果您也覺得重要,那么就需要我們慎重對待,選擇一個安全靠譜的網(wǎng)站建設公司,企業(yè)網(wǎng)站我們建議是要么不做,要么就做好,讓網(wǎng)站能真正成為企業(yè)發(fā)展過程中的有力推手。專業(yè)網(wǎng)站設計公司不一定是大公司,成都創(chuàng)新互聯(lián)公司作為專業(yè)的網(wǎng)絡公司選擇我們就是放心。
Imports System.IO
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim stream As IO.Stream = WebRequest.Create(UrlAdress).GetResponse().GetResponseStream()
'注意urladress為你上面的網(wǎng)頁地址。
Dim sr As StreamReader = New StreamReader(stream, System.Text.Encoding.UTF8)
Label1.Text = Regex.Match(sr.ReadToEnd, "回答采納率").ToString
'sr。告鉛姿readtoend讀取網(wǎng)頁流到末尾,即使用正則表達式從網(wǎng)頁流中提取“回答采納率襪絕”,賦值給Label1.Text ‘沒有則為空
sr.Dispose() '關閉流
End Sub'要提取什么東西用正則激扮表達式最好
End Class
Public Function webCaptureContent(ByVal mWebsiteUrl As String, ByVal mWebsiteType As Boolean) As String
'啟動一次具體的數(shù)據(jù)采集工作,返回采集到的HTML內(nèi)容:要求必須輸入帶://的全地址數(shù)據(jù)
On Error Resume Next
Dim Str_WebContent As String = "請輸入查找網(wǎng)站地址."
Dim wb As WebClient = New WebClient() '//創(chuàng)建一個WebClient實例
If mWebsiteUrl.IndexOf("://") 0 Then
'//獲取或設置用于對向 Internet 資源的請求進行身份驗證的網(wǎng)絡憑據(jù)。(可有可無)
wb.Credentials = CredentialCache.DefaultCredentials
'//從資源下載數(shù)據(jù)梁虧并返回字節(jié)數(shù)組。(加@是因為網(wǎng)址則渣蠢中間有"/"符號)
Dim pagedata As Object = wb.DownloadData(mWebsiteUrl)
'//轉(zhuǎn)換字符
If mWebsiteType Then
Str_WebContent = Encoding.Default.GetString(pagedata)
Else
Str_WebContent = Encoding.UTF8.GetString(pagedata)
End If
End If
Return Str_WebContent '提取出來新聞內(nèi)容,刪除Body前后的多余內(nèi)容,同時孫陪補充上該 Body標記,形成完整的內(nèi)容 Str_WebContent '
End Function
Cookies通過HttpResponse 傳給客戶端,通過HttpRequest 傳回服務端,因此哪洞你可以
設置Response.Cookies集合的值修改Cookie
Response.Cookies("MyCookie")("Data") = TextBox1.Text
通過李升枯讀取Request.Cookies集合的值得到笑敬Cookies的值
Label1.Text =Request.Cookies("MyCookie")("Data") "br"
Dim url As String=" 網(wǎng)址"
Dim httpReq As System.Net.HttpWebRequest
Dim httpResp As System.Net.HttpWebResponse
Dim httpURL As New System.Uri(url)
httpReq = CType(WebRequest.Create(httpURL), HttpWebRequest)
httpReq.Method = "GET"
httpResp = CType(httpReq.GetResponse(), HttpWebResponse)
httpReq.KeepAlive = False ' 獲取或設置一個值,該值態(tài)信指示是否與
Internet資源建立持久連汪擾接。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就帆陵輪是網(wǎng)頁源代碼