The following is a reference fragment: <% ' Function: ASP acquisition code ' Author: wangsdong ' Remarks: Support original program, please keep this information, thank you Url= "Http://sports.sina.com.cn/k/2008-09-15/04593948756.shtml" Str=gethttppage (URL) Title=strcut (str, "Content=strcut (str, "<!--body content begin-->", "<!--body content End-->", 2) Response.Write "News title <br><b>" &title& "</b><br><br><br> news content:<br> "&content Function gethttppage (URL) On Error Resume Next Dim http Set Http=server.createobject ("Microsoft.XMLHTTP") Http.open "Get", Url,false Http.send () If Http.readystate<>4 Then Exit function End If Gethttppage=bytestobstr (Http.responsebody, "GB2312") Set http=nothing If Err.number<>0 Then Response.Write "<p align= ' center ' ><font color= ' red ' ><b> server gets file contents error </b></font></p > " Err.Clear End If End Function Function Bytestobstr (Body,cset) 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 = Cset Bytestobstr = objstream. ReadText Objstream. Close Set objstream = Nothing End Function ' Intercept string, 1. Includes starting and terminating characters, 2. Excluding Function Strcut (Strcontent,startstr,endstr,cuttype) Dim STRHTML,S1,S2 strHTML = strcontent On Error Resume Next Select Case Cuttype Case 1 S1 = InStr (STRHTML,STARTSTR) S2 = InStr (s1,strhtml,endstr) +len (ENDSTR) Case 2 S1 = InStr (strhtml,startstr) +len (STARTSTR) S2 = InStr (S1,STRHTML,ENDSTR) End Select If ERR Then Strcute = "<p align= ' center ' > did not find what was needed. </p> " Err.Clear Exit Function Else Strcut = Mid (STRHTML,S1,S2-S1) End If End Function % > |