
正文
vb.net网页源码下载 vb源代码网站
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
VB下载网页源码
使用 URLDownloadToFile 这个API可以实现vb.net网页源码下载你想要vb.net网页源码下载的功能。
'// 定义
'// 下载网络上vb.net网页源码下载的一个文件到本地
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" ( _
ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long _
) As Long
'// 下载一个文件到本地
Public Function DownloadFile(ByVal strURL As String, ByVal strFile As String) As Boolean
Dim lngReturn As Long
lngReturn = URLDownloadToFile(0, strURL, strFile, 0, 0)
If lngReturn = 0 Then DownloadFile = True
End Function
Private Sub Command1_Click()
Debug.Print DownloadFile("", "D:\1.html")
End Sub
相关问答
Q1: vb.net HttpWebResponse和HttpWebRequest 下载网页源代码 如何等待网页加载完毕在在下?
在HttpWebRequest.GetResponse运行完毕之后,就表示网页已经加载完毕了。
如果是异步获取HttpWebResponse,那么在HttpWebRequest.EndGetResponse之后也表示网页加载完毕了。
Q2: 如何用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就是网页源代码
Q3: 用VB快速下载[网页源代码]
后台下载
声明vb.net网页源码下载:
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
'//调用
然后在代码里直接调用vb.net网页源码下载:
Call URLDownloadToFile(0, "网页地址", "保存到本地文件名和地址", 0, 0)
如
Call URLDownloadToFile(0, "", "c:\1.htm", 0, 0)
相当于另存为
声明vb.net网页源码下载:
Private Declare Function DoFileDownload Lib "shdocvw.dll"(ByVal lpszFile As String) As Long
'//调用
然后在代码里直接调用vb.net网页源码下载:
Dim gourl As String
AdUrl = StrConv("网页地址", vbUnicode)
Call DoFileDownload(gourl)
关于vb.net网页源码下载和vb源代码网站的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






