28,391
社区成员
发帖
与我相关
我的任务
分享
response.Charset="gb2312"
Sub newsSina
dim Content,url,ShowContent
url="http://news.sina.com.cn/news1000/index.shtml"
Content=GetNewsContent(url)
response.write Content
'Content="<a href='www.a.com'>a </a><a href='www.bb.com'>bb </a><a href='www.ccc.com'>ccc </a> "
set re=new RegExp
're.pattern="\[.*?\)"
re.pattern="<li>.*"
re.Global=true
re.IgnoreCase=true
set matches=re.execute(Content)
For Each Match in matches
'ShowContent=ShowContent&right(match.Value,len(match.value)-4)&"<br>"
ShowContent=ShowContent&ChangeURL(right(match.Value,len(match.value)-4))&"<br>"
'response.write ChangeURL(right(match.Value,len(match.value)-4))&"<br>"
next
'ShowContent=ShowContent&"<br><a href=# onclick=vbscript:history.back>返回首页</a>"
'response.write "<font size=2>"&ShowContent&"</font>"
End Sub
Function ChangeURL(str)
'response.write str&"<br>"
set Rep=new regExp
Rep.pattern="http.*\b"
Rep.Global=true
Rep.IgnoreCase=true
set RepMatches=Rep.execute(str)
'Rtn=Rep.test(str)
'response.write Rtn
For Each RepMatch in Repmatches
ChangeURL=replace(str,RepMatch.value,RepMatch.value)
'response.write RepMatch.value&"<br>"
next
End Function
Function GetNewsContent(URL)
set objHttp=server.createobject("Microsoft.XMLHttp")
'objHttp.open "get","http://news.sina.com.cn/news1000/index.shtml";,false
objHttp.open "get",URL,false
objHttp.send()
if objHttp.readystate<>4 then
exit function
end if
GetNewsContent=bytes2BSTR(objHttp.responseBody)
'GetNewsContent=objHttp.responseText
'GetNewsContent=B2B(objHttp.responsebody)
End Function
Function bytes2BSTR(vIn)
dim strReturn
dim i1,ThisCharCode,NextCharCode
strReturn = ""
For i1 = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i1,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i1+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i1 = i1 + 1
End If
Next
bytes2BSTR = strReturn
End Function
Call newsSina