HTMLページ内容ゲット

<%
Function getHTTPPage(url)
dim objXML
set objXML=server.createobject("MSXML2.XMLHTTP")'定义
objXML.open "GET",url,false'打开
objXML.send()'发送
If objXML.readystate<>4 then '判断文档是否已经解析完,以做客户端接受返回消息
exit function
End If
getHTTPPage=BytesToBstr(objXML.responseBody)'返回信息,同时用函数定义编码
set objXML=nothing'关闭
if err.number<>0 then err.Clear
End Function
Function BytesToBstr(body)
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 = "utf-8"
'转换原来默认的UTF-8编码转换成GB2312编码,否则直接用XMLHTTP调用有中文字符的网页得到的将是乱码
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
Dim Url,Html
Url = "http://news.google.co.jp/news?hl=ja&ned=jp&q=%E9%9D%96%E5%9B%BD%E7%A5%9E%E7%A4%BE&ie=UTF-8&scoring=n"
Html = getHTTPPage(Url)
'response.write(Html)
'于 洪流自作
dim splittext
splittext=split(html,"

") dim splitnumber splitnumber=ubound(splittext) dim i,oktext for i = 1 to (splitnumber-1) oktext=splittext(i) oktext=replace(oktext,"

","")
oktext=replace(oktext,"

","")
oktext=replace(oktext,"","")
oktext=replace(oktext,"
","") oktext=replace(oktext,"","")

' response.write ""&oktext&"

#################

"
response.write ""&oktext&"

"
'response.write "1"
next

' response.write ""&Html&""
%>
22
<%=splitnumber%>

コメントを残す

メールアドレスが公開されることはありません。