<% dim id id=request("id") dim myThief,page set myThief=new clsThief myThief.src="http://weather.news.sina.com.cn/text/"&id&"" myThief.steal myThief.cut "","" myThief.change "更多城市","" myThief.change "href=","href=?id=" myThief.change " target=_blank","" page=myThief.value set myThief=nothing page=""&page&"" response.write(page) %> <% '------------------------------ '程序名称:新浪天气小偷 '网站:http://blog.sina.com.cn/aspxt '------------------------------ Class clsThief '____________________ Private value_ '窃取到的内容 Private src_ '要偷的目标URL地址 Private isGet_ '判断是否已经偷过 public property let src(str) '赋值—要偷的目标URL地址/属性 src_=str end property public property get value '返回值—最终窃取并应用类方法加工过的内容/属性 value=value_ end property Public Property get Version Version="直播类 2007" End Property private sub class_initialize() value_="" src_="" isGet_= false end sub private sub class_terminate() end sub private 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 public sub steal() '窃取目标URL地址的HTML代码/方法 if src_<>"" then dim Http set Http=server.createobject("MSXML2.XMLHTTP") Http.open "GET",src_ ,false Http.send() if Http.readystate<>4 then exit sub end if value_=BytesToBSTR(Http.responseBody,"GB2312") isGet_= True set http=nothing if err.number<>0 then err.Clear else response.Write("") end if end sub '转换为小写 public sub LcaseStr() if isGet_= false then call steal() value_=Lcase(value_) end sub '删除偷到的内容中里面的换行、回车符以便进一步加工/方法 public sub noReturn() if isGet_= false then call steal() value_=replace(replace(value_ , vbCr,""),vbLf,"") end sub '对偷到的内容中的个别字符串用新值更换/方法 public sub change(oldStr,str) '参数分别是旧字符串,新字符串 if isGet_= false then call steal() value_=replace(value_ , oldStr,str) end sub '按指定首尾字符串对偷取的内容进行裁减(不包括首尾字符串)/方法 public sub cut(head,bot) '参数分别是首字符串,尾字符串 if isGet_= false then call steal() if instr(value_ , head)>0 and instr(value_ , bot)>0 then value_=mid(value_ ,instr(value_ ,head)+len(head),instr(value_ ,bot)-instr(value_ ,head)-len(head)) else value_= "

对不起,您查看的页面正在升级中,请稍候再试。" end if end sub '将偷取的内容中的绝对URL地址改为本地相对地址 public sub local() dim tempReg set tempReg=new RegExp tempReg.IgnoreCase=true tempReg.Global=true tempReg.Pattern="^(http|https|ftp):(\/\/|////)(\w+.)+(com|net|org|cc|tv|cn|biz|com.cn|net.cn|sh.cn)\/" value_=tempReg.replace(value_ ,"") set tempReg=nothing end sub '对偷到的内容中的符合正则表达式的字符串用新值进行替换/方法 public sub replaceByReg(patrn,str) '参数是你自定义的正则表达式,新值 if isGet_= false then call steal() dim tempReg set tempReg=new RegExp tempReg.IgnoreCase=true tempReg.Global=true tempReg.Pattern=patrn value_=tempReg.replace(value_ ,str) set tempReg=nothing end sub '应用正则表达式对符合条件的内容进行分块采集并组合,最终内容为以隔断的大文本/方法 '通过属性value得到此内容后你可以用split(value,"")得到你需要的数组 public sub pickByReg(patrn) '参数是你自定义的正则表达式 if isGet_= false then call steal() dim tempReg,match,matches,content set tempReg=new RegExp tempReg.IgnoreCase=true tempReg.Global=true tempReg.Pattern=patrn set matches=tempReg.execute(value_) for each match in matches content=content&match.value&"" next value_=content set matches=nothing set tempReg=nothing end sub '类排错模式——在类释放之前应用此方法可以随时查看你截获的内容HTML代码和页面显示效果/方法 public sub debug() dim tempstr tempstr="



      
" response.Write(tempstr) end sub end class %>