原创的一段通过XML来远程抓娶图片的代码

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

<%

'函数1调用XSMXL2.XMLHTTP来进行远程抓取

function getHTTPPage(url)

on error resume next

dim http

set http=server.createobject("MSXML2.XMLHTTP")'使用xmlhttp的方法来获得图片的内容

Http.open "GET",url,false

Http.send()

if Http.readystate<>4 then

exit function

end if

getHTTPPage=Http.responseBody

set http=nothing

if err.number<>0 then err.Clear

end function

'函数2 对数据进行保存

function img(from,tofile)

dim geturl,objStream,imgs

geturl=trim(from)

imgs=gethttppage(geturl)

Set objStream = Server.CreateObject("ADODB.Stream")

objStream.Type =1

objStream.Open

objstream.write imgs

objstream.SaveToFile server.mappath(tofile),2

objstream.Close()

set objstream=nothing

end function

%>

<%=img ("http://stock.jrj.com.cn/htmdata/gifindex/Sh_000001.png","sh1.png")%>

<img src="Sh1.png">

<%=img ("http://stock.jrj.com.cn/htmdata/gifindex/sz_399001.png","sh2.png")%>

<img src="Sh2.png">

<%=img ("http://business.sohu.com/new_world_index.html","gjgshq.html")%>

<iframe name="a" scrolling="auto" frameborder="0" src="gjgshq.html" width="160" height="140"></iframe>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航