Implementation Code for asp to obtain the specified content of a remote webpage

Source: Internet
Author: User

The Code is as follows: Copy codeThe Code is as follows: <%
'Use ASP to obtain remote target webpage specified content, Code provided by Guangzhou Website Construction Co., http://www.jb51.net.
On Error Resume Next
Server. ScriptTimeOut = 9999999
Function getHTTPPage (Path)
T = GetBody (Path)
GetHTTPPage = BytesToBstr (t, "GB2312 ")
End function
Function Newstring (wstr, strng)
Newstring = Instr (lcase (wstr), lcase (strng ))
If Newstring <= 0 then Newstring = Len (wstr)
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
Function GetBody (url)
On error resume next
Set Retrieval = CreateObject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "Get", url, False ,"",""
. Send
GetBody =. ResponseBody
End
Set Retrieval = Nothing
End Function

'Asp starts to get the specified content of a remote webpage
Dim wstr, str, url, start, over, dtime
A = "Start content" 'asp get target webpage content start mark
B = "End Content" 'asp get the end mark of the webpage content
Url = "http:// SC .jb51.net /"
Wstr = getHTTPPage (url)
Start = Newstring (wstr,)
Over = Newstring (wstr, B)
Body = mid (wstr, start, over-start)
Response. write "" & body & "" 'output the obtained webpage content
'Asp: retrieving the specified content of a remote webpage ends.
%>

The above code can get the content of the specified webpage. If it is all, it will be simpler.
Core code:Copy codeThe Code is as follows: 'asp starts to get the specified content of a remote webpage.
Dim wstr, str, url, start, over, dtime
Url = "http:// SC .jb51.net /"
Wstr = getHTTPPage (url)
Body = wstr

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.