vb.net获取url VBNET下载

VB.NET 如何获取网页中的数据

Public Function webCaptureContent(ByVal mWebsiteUrl As String, ByVal mWebsiteType As Boolean) As String

创新互联主营定西网站建设的网络公司,主营网站建设方案,重庆APP开发,定西h5小程序开发搭建,定西网站营销推广欢迎定西等地区企业咨询

'启动一次具体的数据采集工作,返回采集到的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

Return Str_WebContent '提取出来新闻内容,删除Body前后的多余内容,同时补充上该 Body标记,形成完整的内容 Str_WebContent '

End Function

如何用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 ' 获取或设置一个值,该值指示是否与

Internet资源建立持久连接。

Dim reader As StreamReader = _

New StreamReader(httpResp.GetResponseStream,

System.Text.Encoding.GetEncoding(-0))

Dim respHTML As String = reader.ReadToEnd() 'respHTML就是网页源代码

vb.net得到收藏夹中URL文件的URL地址

打开IE浏览器,再打开收藏夹,里面就有你收藏了的一些网址,想看哪个就选中他再右击---属性。就可以知道他的URL地址了

vb.net 如何指定访问来路来访问一个URL?

'GET数据通用模板,返回源码

Function DownBitmap(ByVal URL_Post As String, ByVal Referer_Post As String, ByVal Accept_Post As String, ByVal UserAgent_Post As String _

, ByVal KeepAlive_Post As Boolean, ByVal CookieContainer_Post As CookieContainer) As Bitmap

Dim HttpPostUrl As New System.Uri(URL_Post)

Dim reqp As HttpWebRequest

reqp = CType(WebRequest.Create(HttpPostUrl), HttpWebRequest)

reqp.Method = "GET"

reqp.Referer = Referer_Post

reqp.Accept = Accept_Post

reqp.UserAgent = UserAgent_Post

reqp.KeepAlive = KeepAlive_Post

reqp.CookieContainer = CookieContainer_Post '设置Cookie

Dim resP As WebResponse = reqp.GetResponse

Dim bmp As Bitmap = New Bitmap(resP.GetResponseStream)

resP.Close() '关闭

Return bmp

End Function


网站名称:vb.net获取url VBNET下载
转载来源:http://hbruida.cn/article/dooigic.html