使用webbrowser控件來加載網(wǎng)頁,然后再
成都創(chuàng)新互聯(lián)是專業(yè)的畢節(jié)網(wǎng)站建設公司,畢節(jié)接單;提供網(wǎng)站設計制作、做網(wǎng)站,網(wǎng)頁設計,網(wǎng)站設計,建網(wǎng)站,PHP網(wǎng)站建設等專業(yè)做網(wǎng)站服務;采用PHP框架,可快速的進行畢節(jié)網(wǎng)站開發(fā)網(wǎng)頁制作和功能擴展;專業(yè)做搜索引擎喜愛的網(wǎng)站,專業(yè)的做網(wǎng)站團隊,希望更多企業(yè)前來合作!
Private
Sub
WebBrowser
1_DocumentCompleted下通過使用WebBrowser1.Document.Body.
InnerHtml
來獲取網(wǎng)頁的源代碼,或使用
WebBrowser1.Document.Body.InnerText來獲取網(wǎng)頁中的文本。之后可以通過字符串控制指令或者
正則表達式
來精確獲取到你所需的數(shù)據(jù)。
'首先用webclient獲得貼吧首頁的源碼。這里以vb,net貼吧為例
Private Sub BtnGetNum_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnGetNum.Click
Dim url As String = ""'vb.net吧的首頁
Dim MyClient As System.Net.WebClient = New System.Net.WebClient
Dim MyReader As New System.IO.StreamReader(MyClient.OpenRead(url), System.Text.Encoding.Default) '定義新的文件流并讀取網(wǎng)頁文件數(shù)據(jù)
Dim longTxt As String = MyReader.ReadToEnd '寫入
'分析源碼,獲取主題數(shù)
Dim startStr As String = "共有主題數(shù)"
Dim startNum As Long = InStr(longTxt, startStr) + Len(startStr) + 18
Dim resStr As String = ""
Do Until Mid(longTxt, startNum, 1) = “"
resStr = resStr Mid(longTxt, startNum, 1)
startNum = startNum + 1
Loop
Label1.Text = resStr '顯示主題數(shù)
End Sub
我想在窗體上加幾個label用來提示錯誤會更好??!其中用戶名為label1,密碼為label2,確認密碼為label3, 提交為button1,重置為button2,事例:其中名稱為Warehouse的SQL數(shù)據(jù)庫里面有一張Administrator1表有用戶名和密碼兩個字段。
'這里是添加的引用
Imports System.Data
Imports System.Data.SqlClient
'提交按鈕
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text =
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 ' 獲取或設置一個值,該值指示是否與
Internet資源建立持久連接。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就是網(wǎng)頁源代碼
System.Diagnostics.Process.Start("")
或者用 WebBrowser控件,代碼 WebBrowser1.Url = New System.Uri("")
網(wǎng)頁是提前在右邊的工程里添加的webform,點擊一個商品調用這個頁就是了,不是現(xiàn)生成的.