保存网页文件
如何快速将网页内容保存为文本文件?
要用什么控件呢?
问题点数:30、回复次数:2Top
1 楼kmlxk(xiaoKKKK)回复于 2005-08-17 10:51:46 得分 15
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
If URLDownloadToFile(0, strURL, strFileName, 0, 0) = 0 Then '如果下载成功则返回0Top
2 楼cly2004(学习ing!)回复于 2005-08-17 11:07:23 得分 15
这是网页取数据过程:
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP") 'XML中的XMLHTTP组件
Http.open "GET",url,false 'url目标网页地址
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function
直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
行不行你试一下跟我说
Top




