📄 index2.asp
字号:
<!--
------------------------------------
---- 说明-很重要 --
-- --
--文件名: index2.asp --
--功能 :获得天气参数 --
--如果获得失败,请修改相关参数 --
--蚊子小偷之--雅虎天气 --
--QQ:127029751 by www.818699.com--
------------------------------------
--->
<!--#include file=config.asp-->
<%
dim weburl,cx_city
'请修改为你的网址
weburl="www.818699.com"
cx_city=request("city")
'cx_city=Server.Urlencode(cx_city)
if cx_city = "" then
cx_city = "河池"
end if
'远程截取函数开始
Server.ScriptTimeOut=9999999
Function getHTTPPage(Path)
t = GetBody(Path)
getHTTPPage=BytesToBstr(t,"utf-8")
End function
Function GetBody(url)
on error resume next
Set Retrieval = CreateObject("Msxml2.ServerXMLHTTP")
With Retrieval
.Open "post", url, False, "", ""
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body,Cset)
dim objstream
s="stream"
set objstream = Server.CreateObject("adodb."&s)
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
Function Newstring(wstr,strng)
Newstring=Instr(lcase(wstr),lcase(strng))
if Newstring<=0 then Newstring=Len(wstr)
End Function
'
'截取网址
url="http://weather.cn.yahoo.com/weather.html?city="&cx_city
wstr=getHTTPPage(url)
'截取数据
set reg=new Regexp
reg.Multiline=True
reg.Global=Flase
reg.IgnoreCase=true
reg.Pattern=""&cx_cj1&"((.|\n)*?)"&cx_cj2&""
Set matches = reg.execute(wstr)
For Each match1 in matches
bodypage=match1.Value
if bodypage = "" then
bodypage = "noting"
end if
Next
Set matches = Nothing
Set reg = Nothing
bodypage=replace(bodypage,"http://cn.yimg.com/i/js/wea","js")
bodypage=replace(bodypage,"http://cn.yimg.com/i/wea/v1","images")
bodypage=replace(bodypage,"http://cn.yimg.com/i/wea","images/gif")
response.write bodypage
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -