vb.net获取网页源码 获取网页源代码

VB怎么获取网页源码

1)使用MICROSOFT INTERNET TRANSFER CONTROL的,代码如下:

创新互联建站主营市中网站建设的网络公司,主营网站建设方案,App定制开发,市中h5微信平台小程序开发搭建,市中网站营销推广欢迎市中等地区企业咨询

Dim strhtml As String

Dim STRURL As String

STRURL=""

strhtml = Inet1.OpenURL(STRURL)

2)用System.Net命空间下的HttpWebRequest来取得,代码如下:

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中如何利用api函数获取网页源代码???

Dim MyClient As WebClient = New WebClient

Dim MyReader As New System.IO.StreamReader(MyClient.OpenRead(url), System.Text.Encoding.Default) '定义新的文件流并读取网页文件数据,url表示需要打开的网页地址

Dim longTxt As String = MyReader.ReadToEnd 'longtxt存储了网页的源码

MyReader.Close()

如何用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 不使用控件获取某网页源代码

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

Dim MyClient As Net.WebClient = New Net.WebClient

Dim MyReader As New System.IO.StreamReader(MyClient.OpenRead(""), System.Text.Encoding.Default)

Dim MyWebCode As String = MyReader.ReadToEnd

Me.RichTextBox1.Text = MyWebCode

MyReader.Close()

End Sub

VB.NET获取需要登录后的源码

很简单的。这个最基本的了。

就是从数据库表中 找出一个记录,名称和密码都和你输入的一样的记录,就表示登陆成功。

简单的思路:(密码也没有加密等)

dim dt As New DataTable

dim cmd As New SqlCommand

With cmd

.CommandText = "Select * From Users Where UserName=@UserName and UserPwd=@UserPwd"

.Parameters.Add(New SqlClient.SqlParameter("@UserName", "=你输入的用户名TextBox1.Text"))

.Parameters.Add(New SqlClient.SqlParameter("@strColorNo", "=你输入的密码TextBox2.Text"))

End With

dt =SqlHelper.GetDatatable(cmd)

if dt.rows.count0 then

msgbox "ok"

else

msgbox "error"

end if


新闻名称:vb.net获取网页源码 获取网页源代码
本文路径:http://azwzsj.com/article/dooched.html