i found some info
所在版块:社会百科 发贴时间:2004-01-14 15:05

用户信息
复制本帖HTML代码
高亮: 今天贴 X 昨天贴 X 前天贴 X 
but not very sure about it.
----->

如何利用xml来截取别人网站的内容

将下面代码保存为html格式,只要你的浏览器版本在IE5.0以上就行了.由于要数据要经过转换所以速度会有点慢,不知大家有什么好的方法欢迎一起来讨论lzppcc@21cn.com

<script language="VBScript">
Option Explicit
Dim NextCharCode,ThisCharCode,i,strReturn,Retrieval,T,Start,Start2,get_url,start_char,end_char,start_char_len

get_url="http://news.sina.com.cn/news1000.shtml" //---要截取的页面
start_char="<!--新闻开始-->" //要从哪个地方开始截取
end_char="<!--新闻结束-->" //到哪个地方结束
start_char_len=len(start_char) //开始字符串长度


T=GetURL(get_url)
T=bytes2BSTR(T) //将数据转换为字符型式
start=Instr(1,t,start_char)
start2=Instr(start,t,end_char)
t=mid(T,start+start_char_len,start2-start-start_char_len) //取出数据
document.write t


Function GetURL(url)
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
'GetURL = .ResponseText
GetURL = .Responsebody
End With
Set Retrieval = Nothing
End Function

Function bytes2BSTR(vIn)
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>

.
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!

Put your OWN COOL signature here!
 相关帖子 我要回复↙ ↗回到正文
a question regarding webpage design 楂楂兔   (330 bytes , 438reads )
这也太阴了吧。。 hula   (241 bytes , 227reads )
i found some info 楂楂兔   (1398 bytes , 247reads )
there's also a software 楂楂兔   (372 bytes , 249reads )