<% @ Language = "VBScript" codePage = "936" %> <br/> <% <br/> 'function: ASP collection <SPAN class = 'wp _ keywordlink '> Code </span> <br/>' Author: wangsdong <br/> 'remarks: the original <SPAN class = 'wp _ keywordlink '> Program </span> is supported. Keep this information, thank you <br/> url = "http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml" <br/> STR = gethttppage (URL) <br/> Title = strcut (STR, "<H1 id =" "artibodytitle" "style =" "color: # 03005c;" ">", "</p>", 2) <br/> content = strcut (STR, "<! -- Body content begin --> "," <! -- Body content end --> ", 2) <br/> response. write "news title <br> <B>" & Title & "</B> <br> news content: <br> "& content <br/> function gethttppage (URL) <br/> on error resume next <br/> dim HTTP <br/> set HTTP = server. createobject ("Microsoft. XMLHTTP ") <br/> HTTP. open "get", URL, false <br/> HTTP. send () <br/> if HTTP. readystate <> 4 then <br/> exit function <br/> end if <br/> gethttppage = bytestobstr (HTTP. responsebody, "gb2312") <br/> set HT TP = nothing <br/> If err. number <> 0 then <br/> response. write "<p align = 'center'> <font color = 'red'> <B> An error occurred while obtaining the file content on the server </B> </font> </P>" <br/> err. clear <br/> end if <br/> end function </P> <p> function bytestobstr (body, cset) <br/> dim objstream <br/> set objstream = server. createobject ("ADODB. stream ") <br/> objstream. type = 1 <br/> objstream. mode = 3 <br/> objstream. open <br/> objstream. write body <br/> objstream. positi On = 0 <br/> objstream. type = 2 <br/> objstream. charset = cset <br/> bytestobstr = objstream. readtext <br/> objstream. close <br/> set objstream = nothing <br/> end function </P> <p> 'intercept string, 1. including start and end characters, 2. not including <br/> function strcut (strcontent, startstr, endstr, cuttype) <br/> dim strhtml, S1, s2 <br/> strhtml = strcontent <br/> on error resume next <br/> select case cuttype <br/> case 1 <br/> S1 = instr (strhtml, startstr) <Br/> S2 = instr (S1, strhtml, endstr) + Len (endstr) <br/> case 2 <br/> S1 = instr (strhtml, startstr) + Len (startstr) <br/> S2 = instr (S1, strhtml, endstr) <br/> end select <br/> If err then <br/> strcute = "<p align = 'center'> the required content is not found. </P> "<br/> err. clear <br/> exit function <br/> else <br/> strcut = mid (strhtml, S1, S2-S1) <br/> end if <br/> end function <br/> %>