<%
Dim Cityid
Cityid= Request.Querystring("id") url="http://weather.114la.com/weather.php?cityid="&Cityid&""
str=getHTTPPage(url) str=Replace(str,"114la","xunchn")
title=strcut(str," <!--table开始-->"," <!--开始:底部-->",2)
%>
<%
Function getHTTPPage(url)
On Error Resume Next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate <>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"utf-8")
set http=nothing
If Err.number <>0 then
Response.Write " <p align='center'> <font color='red'> <b>服务器获取文件内容出错 </b> </font> </p>"
Err.Clear
End If
End Function 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 '截取字符串,1.包括起始和终止字符,2.不包括
Function strCut(strContent,StartStr,EndStr,CutType)
Dim strHtml,S1,S2
strHtml = strContent
On Error Resume Next
Select Case CutType
Case 1
S1 = InStr(strHtml,StartStr)
S2 = InStr(S1,strHtml,EndStr)+Len(EndStr)
Case 2
S1 = InStr(strHtml,StartStr)+Len(StartStr)
S2 = InStr(S1,strHtml,EndStr)
End Select
If Err Then
strCute = " <p align='center'>没有找到需要的内容。 </p>"
Err.Clear
Exit Function
Else
strCut = Mid(strHtml,S1,S2-S1)
End If
End Function
%>
<%=str%>现在学习php,网站上现在用的,现在想改成php,研究了一个多星期了,还是不行,请教!!!最好能给出代码,并注释一下!!好学习,谢谢分不多,给一点吧,
Dim Cityid
Cityid= Request.Querystring("id") url="http://weather.114la.com/weather.php?cityid="&Cityid&""
str=getHTTPPage(url) str=Replace(str,"114la","xunchn")
title=strcut(str," <!--table开始-->"," <!--开始:底部-->",2)
%>
<%
Function getHTTPPage(url)
On Error Resume Next
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate <>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"utf-8")
set http=nothing
If Err.number <>0 then
Response.Write " <p align='center'> <font color='red'> <b>服务器获取文件内容出错 </b> </font> </p>"
Err.Clear
End If
End Function 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 '截取字符串,1.包括起始和终止字符,2.不包括
Function strCut(strContent,StartStr,EndStr,CutType)
Dim strHtml,S1,S2
strHtml = strContent
On Error Resume Next
Select Case CutType
Case 1
S1 = InStr(strHtml,StartStr)
S2 = InStr(S1,strHtml,EndStr)+Len(EndStr)
Case 2
S1 = InStr(strHtml,StartStr)+Len(StartStr)
S2 = InStr(S1,strHtml,EndStr)
End Select
If Err Then
strCute = " <p align='center'>没有找到需要的内容。 </p>"
Err.Clear
Exit Function
Else
strCut = Mid(strHtml,S1,S2-S1)
End If
End Function
%>
<%=str%>现在学习php,网站上现在用的,现在想改成php,研究了一个多星期了,还是不行,请教!!!最好能给出代码,并注释一下!!好学习,谢谢分不多,给一点吧,
Dim Cityid
Cityid= Request.Querystring("id") url="http://weather.114la.com/weather.php?cityid="&Cityid&""
str=getHTTPPage(url) str=Replace(str,"114la","xunchn")
title=strcut(str," <!--table开始-->"," <!--开始:底部-->",2)
%>
寫這段的注釋就行了,大概猜得出一點東西
就是獲取http://weather.114la.com/weather.php?cityid="&Cityid&"" 這頁的內容
Dim Cityid
Cityid= Request.Querystring("id") url="http://weather.114la.com/weather.php?cityid="&Cityid&""
str=getHTTPPage(url) str=Replace(str,"114la","xunchn")
title=strcut(str," <!--table开始-->"," <!--开始:底部-->",2)
%>
<?php
$Cityid=$_GET[id]; url="http://weather.114la.com/weather.php?cityid="&Cityid&""
$str=file(url); $str=str_replace("114la","xunchn",$str)
$bpos=strpos($str," <!--table开始-->")+strlen(" <!--table开始-->");
$epos=strpos($str," <!--开始:底部-->");
title=substr($str,$bpos,$epos-$bpos);
?> 未經測試,快點結帳讓我拿分走人