VB.net获取框架网页 vbnet folderbrowserdialog

VB.NET 如何获取网页中的数据Public Function webCaptureContent(ByVal mWebsiteUrl As String, ByVal mWebsiteType As Boolean) As String
'启动一次具体的数据采集工作,返回采集到的HTML内容:要求必须输入带://的全地址数据
On Error Resume Next
Dim Str_WebContent As String = "请输入查找网站地址."
Dim wb As WebClient = New WebClient()'//创建一个WebClient实例
If mWebsiteUrl.IndexOf("://")0 Then
'//获取或设置用于对向 Internet 资源的请求进行身份验证的网络凭据 。(可有可无)
wb.Credentials = CredentialCache.DefaultCredentials
'//从资源下载数据并返回字节数组 。(加@是因为网址中间有"/"符号)
Dim pagedata As Object = wb.DownloadData(mWebsiteUrl)
'//转换字符
If mWebsiteType Then
Str_WebContent = Encoding.Default.GetString(pagedata)
Else
Str_WebContent = Encoding.UTF8.GetString(pagedata)
End If
End If
ReturnStr_WebContent'提取出来新闻内容,删除Body前后的多余内容,同时补充上该 Body标记,形成完整的内容Str_WebContent'
End Function
VB.net中如何获取WebBrowser网页中的框架网页的内容HtmlDocument doc= webBrowser1.Document.Window.Frames["frame1"].Document;
HtmlElement el= doc.GetElementById("input的ID");
el.SetAttribute("value","111");
求VB.NET读取网页内容写法Imports System.Net
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为你上面的网页地址 。
Dim sr As StreamReader = New StreamReader(stream, System.Text.Encoding.UTF8)
Label1.Text = Regex.Match(sr.ReadToEnd, "回答采纳率").ToString
'sr 。readtoend读取网页流到末尾 , 即使用正则表达式从网页流中提取“回答采纳率”,赋值给Label1.Text ‘没有则为空
sr.Dispose() '关闭流
End Sub'要提取什么东西用正则表达式最好
End Class
如何用vb webbrowser获取带框架网页的全部源代码?用vb webbrowser获取带框架网页的全部源代码,指令如下:
WebBrowser1.Document.frames(0).Document.documentElement.outerHTML
【VB.net获取框架网页 vbnet folderbrowserdialog】遍历框架就可以得到所有的(WebBrowser1.Document.frames(0).count框架个数) 。
源代码(也称源程序)是指未编译的按照一定的程序设计语言规范书写的文本文件,是一系列人类可读的计算机语言指令 。
在现代程序语言中,源代码可以是以书籍或者磁带的形式出现,但最为常用的格式是文本文件,这种典型格式的目的是为了编译出计算机程序 。计算机源代码的最终目的是将人类可读的文本翻译成为计算机可以执行的二进制指令,这种过程叫做编译,通过编译器完成 。
vb.net获取网页中对话框的内容'api constant declarations...
Const WM_GETTEXT As Long = HD
Const WM_GETTEXTLENGTH As Long = HE
Const GW_ENABLEDPOPUP As Long = 6
Const BM_CLICK As Long = HF5
Const GW_CHILD As Long = 5
Const GW_HWNDNEXT As Long = 2
'function to retrieve the popup window associated with the form, as well as to find the child windows of the popup...
Private Declare Function GetWindow Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal uCmd As Integer) As IntPtr
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
'sendmessage overload that is used to send messages to the button on the dialog window...
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessage" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
ByVal wParam As Integer, ByRef lParam As IntPtr) As IntPtr
'sendmessage overloads used to retrieve the window text...
Private Declare Function SendMessageA Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal Msg As Integer, _
ByVal wParam As IntPtr, ByRef lParam As IntPtr) As IntPtr
DllImport("User32.dll", CharSet:=CharSet.Auto, Entrypoint:="SendMessage") _
Public Shared Function SendMessageString(ByVal hwnd As IntPtr, _
ByVal wMsg As Integer, ByVal wparam As Integer, ByVal lparam As System.Text.StringBuilder) As IntPtr
End Function
'these next three functions are used to enumerate the Windows handles of all Windows sited on the specified parent...
Function GetChildWindowHandles(ByVal ParentWindowHandle As IntPtr) As ArrayList
Dim b As Boolean
Dim ptrChild As IntPtr
Dim clsRet As New ArrayList
'get first child handle...
ptrChild = GetChildWindowHandle(ParentWindowHandle)
Do Until ptrChild.Equals(IntPtr.Zero)
'add to collection of handles...
clsRet.Add(ptrChild)
'get next child...
ptrChild = GetNextWindowHandle(ptrChild)
Loop
'return...
Return clsRet
End Function
Function GetChildWindowHandle(ByVal ParentWindowHandle As IntPtr) As IntPtr
Return GetWindow(ParentWindowHandle, GW_CHILD)
End Function
Function GetNextWindowHandle(ByVal CurrentWindowhandle As IntPtr) As IntPtr
Return GetWindow(CurrentWindowhandle, GW_HWNDNEXT)
End Function
'this function returns the text of the window, used so that we can confirm that we have the right dialog window...
Function GetWindowText(ByVal WindowHandle As IntPtr) As String
Dim ptrRet As IntPtr
Dim ptrLength As IntPtr
'get length for buffer...
ptrLength = SendMessageA(WindowHandle, WM_GETTEXTLENGTH, IntPtr.Zero, IntPtr.Zero)
'create buffer for return value...
Dim sb As New System.Text.StringBuilder(ptrLength.ToInt321)
'get window text...
ptrRet = SendMessageString(WindowHandle, WM_GETTEXT, ptrLength.ToInt321, sb)
'get return value...
Return sb.ToString
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ptrDialogWindow As IntPtr = FindWindow(vbNullString, "Microsoft Internet Explorer")
Dim clsChildHandles As ArrayList = GetChildWindowHandles(ptrDialogWindow)
For Each ptrHandle As IntPtr In clsChildHandles
Dim str As String = GetWindowText(ptrHandle)
If str"" And str"确定" Then
MsgBox(str)
End If
Next
End Sub
如何用vb.net获得网页的源代码Dim url As String=" 网址"
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 ' 获取或设置一个值VB.net获取框架网页,该值指示是否与
Internet资源建立持久连接 。
Dim reader As StreamReader = _
New StreamReader(httpResp.GetResponseStream,
System.Text.Encoding.GetEncoding(-0))
Dim respHTML As String = reader.ReadToEnd() 'respHTML就是网页源代码
VB.net获取框架网页的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于vbnet folderbrowserdialog、VB.net获取框架网页的信息别忘了在本站进行查找喔 。

    推荐阅读