推薦:ASP返回某字符串最后出現的位置% dwwwStr= divdwww.cn/divdivwww.dwww.cn/div設計家園 dwwwStr= InStrRev(dwwwStr,/div) response.write dwwwStr % InstrRev 描述 返回某字符串在另一個字符串中出現的從結尾計起的位置。 語法 InstrRev(string1, string2[, start[, compare]]) InstrRe
早上在公司上班的時候,看到外邊下起了雪,2008年的第一場雪,比以往來的更晚一點,呵呵,冷啊。。
于是想辦法寫抓天氣預報的程序,看到了QQ的天氣預報挺不錯的。。呵呵。。就抓你了!
如圖:
代碼:
<%
'On Error Resume Next
'作者:無情 來源: 轉載請保留出處
Response.ContentType="text/html; charset=gb2312"
Call weather()
Sub weather()
url="http://weather.news.qq.com/inc/07_ss252.htm" '上海的天氣
Call IsObjInstalled("Microsoft.XMLHTTP")
weatherStr= getHTTPPage(url)
if weatherStr="" then
response.write "抱歉,天氣預報加載失敗!"
else
set reg=new Regexp
reg.Multiline=True
reg.Global=false
reg.IgnoreCase=true
reg.Pattern="<td height=""77"" class=""wht2 lk37"">((.|/n)*?)</td>"
Set matches = reg.execute(weatherStr)
For Each match1 in matches
weatherStr=match1.Value
Next
Set matches = Nothing
Set reg = Nothing
if InStr(weatherStr,"沒有找到與")>0 then
response.write "抱歉,天氣預報加載失敗!"
Else
weatherStr=Replace(weatherStr,"<td height=""77"" class=""wht2 lk37"">","")
weatherStr=Replace(weatherStr,"<div class=""txbd"">","")
weatherStr=Replace(weatherStr,"</div>"," ")
weatherStr=Replace(weatherStr,"</td>","")
response.write "上海天氣預報:"&weatherStr&""
end if
end if
End Sub
'// 采用 Microsoft.XMLHTTP 組件采集數據 分享:解析Asp實現Dig程序中的投票ASP做一個dig程序中的投票(有的叫頂一下,踩一下),由于代碼較長,只貼出核心部分:投票中的代碼 網頁顯示投票的部分: div class=Vote1script src='/voteResult.asp?id=1action=view'/script/div 效果如圖: 520)this.width=500 border=0>,然后點投一
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=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<>0 then err.Clear
End function
新聞熱點
疑難解答