用VB快速下载[网页源代码]
高速下载某网页源代码,如何用API实现,用webBrowser和inet感觉都太慢.比如我想下载"http://hao123.com"的源码,具体如何实现?谢谢....
高速下载某网页源代码,如何用API实现,用webBrowser和inet感觉都太慢.
比如我想下载"http://hao123.com"的源码,具体如何实现?谢谢. 展开
比如我想下载"http://hao123.com"的源码,具体如何实现?谢谢. 展开
4个回答
展开全部
后台下载
声明:
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
'//调用
然后在代码里直接调用:
Call URLDownloadToFile(0, "网页地址", "保存到本地文件名和地址", 0, 0)
如
Call URLDownloadToFile(0, "http://www.baidu.com/", "c:\1.htm", 0, 0)
相当于另存为
声明:
Private Declare Function DoFileDownload Lib "shdocvw.dll"(ByVal lpszFile As String) As Long
'//调用
然后在代码里直接调用:
Dim gourl As String
AdUrl = StrConv("网页地址", vbUnicode)
Call DoFileDownload(gourl)
声明:
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
'//调用
然后在代码里直接调用:
Call URLDownloadToFile(0, "网页地址", "保存到本地文件名和地址", 0, 0)
如
Call URLDownloadToFile(0, "http://www.baidu.com/", "c:\1.htm", 0, 0)
相当于另存为
声明:
Private Declare Function DoFileDownload Lib "shdocvw.dll"(ByVal lpszFile As String) As Long
'//调用
然后在代码里直接调用:
Dim gourl As String
AdUrl = StrConv("网页地址", vbUnicode)
Call DoFileDownload(gourl)
万企明道
2024-08-07 广告
2024-08-07 广告
低代码开发系统,作为上海万企明道软件有限公司的重要产品方向,极大地简化了软件开发流程。它允许非专业开发者通过图形化界面与少量代码,快速构建应用程序。这一系统降低了技术门槛,加速了项目上线时间,同时提升了软件的灵活性和可维护性。我们致力于为用...
点击进入详情页
本回答由万企明道提供
展开全部
Private Declare Function DoFileDownload Lib "shdocvw.dll" (ByVal lpszFileAsString) As Long
Private Sub Command1_Click()
Dim sDownload As String
sDownload=StrConv(Text1.Text,vbUnicode)
Call DoFileDownload(sDownload)
End Sub
或者
Private Declare Function URLDownloadToFile Lib "urlmon.dll" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim sDownload As String
sDownload=StrConv(Text1.Text,vbUnicode)
Call DoFileDownload(sDownload)
End Sub
或者
Private Declare Function URLDownloadToFile Lib "urlmon.dll" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
URLDownLoadToFile函数,API里的
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
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
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2008-11-01
展开全部
'============================
'XmlHttp函数
'GetBody("http://hao123.com")
'============================
Public Function GetBody(ByVal URL$, Optional ByVal Coding$ = "GB2312")
Dim ObjXML
On Error Resume Next
Set ObjXML = CreateObject("Microsoft.XMLHTTP")
With ObjXML
.Open "Get", URL, False, "", ""
.setRequestHeader "If-Modified-Since", "0"
.SEnd
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody, Coding)
Set ObjXML = Nothing
End Function
Public Function BytesToBstr(strBody, CodeBase)
Dim ObjStream
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write strBody
.Position = 0
.Type = 2
.Charset = CodeBase
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
End Function
'XmlHttp函数
'GetBody("http://hao123.com")
'============================
Public Function GetBody(ByVal URL$, Optional ByVal Coding$ = "GB2312")
Dim ObjXML
On Error Resume Next
Set ObjXML = CreateObject("Microsoft.XMLHTTP")
With ObjXML
.Open "Get", URL, False, "", ""
.setRequestHeader "If-Modified-Since", "0"
.SEnd
GetBody = .ResponseBody
End With
GetBody = BytesToBstr(GetBody, Coding)
Set ObjXML = Nothing
End Function
Public Function BytesToBstr(strBody, CodeBase)
Dim ObjStream
Set ObjStream = CreateObject("Adodb.Stream")
With ObjStream
.Type = 1
.Mode = 3
.Open
.Write strBody
.Position = 0
.Type = 2
.Charset = CodeBase
BytesToBstr = .ReadText
.Close
End With
Set ObjStream = Nothing
End Function
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询