ASP collection code

Source: Internet
Author: User

<% @ 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/> %>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.