真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

vb.net網(wǎng)頁值,vbnet web

VB.net webBrowser控件獲取如何獲取下面這網(wǎng)頁元素的值

我將你的上面的html代碼復(fù)制到一個test.html文件中

創(chuàng)新互聯(lián)網(wǎng)絡(luò)公司擁有十多年的成都網(wǎng)站開發(fā)建設(shè)經(jīng)驗,上千客戶的共同信賴。提供成都網(wǎng)站建設(shè)、成都做網(wǎng)站、網(wǎng)站開發(fā)、網(wǎng)站定制、買友情鏈接、建網(wǎng)站、網(wǎng)站搭建、響應(yīng)式網(wǎng)站、網(wǎng)頁設(shè)計師打造企業(yè)風(fēng)格,提供周到的售前咨詢和貼心的售后服務(wù)

html

head

titleTest Page/title

/head

body

input name="txtCSRQ" class="textbox" id="txtCSRQ" type="text" readonly="readonly" value="1993-05-10"/

/body

/html

然后在vb.net的webbrowser中加載這個test.html,加載完畢后點擊一個按鈕獲取input的value值,實現(xiàn)代碼如下:

' 此方法為Form1的加載事件

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

' 加載本地文檔test.html

WebBrowser1.Url = New Uri(String.Format("{0}/test.html", Application.StartupPath))

' 文檔沒有加載完畢之前將按鈕禁用

Button1.Enabled = False

End Sub

' 此方法為Button1的Click事件

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Dim doc As HtmlDocument = WebBrowser1.Document

' 查找ID為txtCSRQ的元素

Dim element As HtmlElement = doc.GetElementById("txtCSRQ")

' 如果找到了改元素

If element IsNot Nothing Then

' 顯示該元素的值

MessageBox.Show(element.GetAttribute("value"))

End If

End Sub

' 此方法為WebBrowser的DocomentCompleted事件

Private Sub WebBrowser1_DocumentCompleted(sender As Object, e As WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted

' 文檔test.html加載完畢后,使按鈕可用

Button1.Enabled = True

End Sub

VB.NET 如何獲取網(wǎng)頁中的數(shù)據(jù)

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

'//獲取或設(shè)置用于對向 Internet 資源的請求進行身份驗證的網(wǎng)絡(luò)憑據(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

VB.NET webBrowser 怎么改網(wǎng)頁元素的VALUE值 和點擊BUTTON

For Each h_e As HtmlElement In WebBrowser1.Document.GetElementsByTagName("Value")

h_e.OuterText = "修改后的值"

Next

是執(zhí)行button的click事件嗎?不過要知道button的id才可以。

webbrowser1.Document.GetElementById(button的id).InvokeMember("click");

vb.net如何獲取網(wǎng)頁的cookie

這個問題有點意思,但題主表意不明,確切的說應(yīng)該分Web端和客戶端兩種情況。

想來問到這個問題的不應(yīng)該是開發(fā)Web端的,說說客戶端的吧:

1、HttpWebRequest.CookieContainer

Cookies通過HttpResponse傳給客戶端,通過HttpRequest傳回服務(wù)端,因此你可以

設(shè)置Response.Cookies集合的值修改Cookie

1

Response.Cookies("MyCookie")("Data") = myCookie

通過讀取Request.Cookies集合的值得到Cookies的值

1

myCookie =Request.Cookies("MyCookie")("Data") ""

2、本人自編的一個函數(shù),放到一個模塊里直接調(diào)用即可:

Dim myCookie As String

Public Function LoginAnGetCookie(ByRef sUser As String, ByRef sPass As String) As String()

On Error Resume Next

REM 登錄網(wǎng)站并獲得cookie

Dim url As String = "網(wǎng)站地址"

Dim postData As String = "sUser=" sUser "sPass=" sPass '假設(shè)傳值的是這樣的,實際中可用Fiddler抓取。

Dim wc As System.Net.WebClient = New System.Net.WebClient

Rem wc.Headers.Add("Cookie", myCookie) '可講第一次獲得的Cookie賦值給myCookie,然后在此處傳值給網(wǎng)站即可

wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded")

wc.Headers.Add("UserAgent", "Mozilla/5.0(iPad; U; CPU iPhone OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B314 Safari/531.21.10)")

Dim sHtml As String = wc.UploadString(url, "POST", postData)

Dim arrAllKeys() As String = wc.ResponseHeaders.AllKeys

Dim sCookies As String = "Set-Cookie"

For i As Integer = 0 To arrAllKeys.Length - 1

If arrAllKeys(i).Equals("Set-Cookie") Then sCookies = wc.ResponseHeaders.Get(i)

Next i

Return New String() {sHtml, sCookies} '返回二維數(shù)組,其中LoginAnGetCookie(0)是網(wǎng)頁源代碼,LoginAnGetCookie(1)是登錄后的Cookie

End Function


標題名稱:vb.net網(wǎng)頁值,vbnet web
URL網(wǎng)址:http://weahome.cn/article/dseecgg.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部