XMLHTTP Crawl page Content 1

Source: Internet
Author: User
Tags chr

<%
On Error Resume Next
server.scripttimeout=9999999
Function Gethttppage (Path)
t = GetBody (Path)
Gethttppage=bytestobstr (T, "GB2312")
End Function

Function Bytes2bstr (vIn)
Strreturn = ""
For j = 1 to LenB (vIn)
Thischarcode = AscB (MidB (vin,j,1))
If Thischarcode < &h80 Then
Strreturn = Strreturn & Chr (Thischarcode)
Else
Nextcharcode = AscB (MidB (vin,j+1,1))
Strreturn = Strreturn & Chr (CLng (thischarcode) * &h100 + CInt (nextcharcode))
j = j + 1
End If
Next
Bytes2bstr = Strreturn
End Function

Function getbody (URL)
On Error Resume Next
Set retrieval = CreateObject ("Microsoft.XMLHTTP")

Retrieval.open "Get", url, False, "", ""
Retrieval.send
GetBody =retrieval.responsebody

Set retrieval = Nothing
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 newstring (WSTR,STRNG)
Newstring=instr (LCase (WSTR), LCase (STRNG))
If Newstring<=0 then Newstring=len (WSTR)
End Function

%>

<%
Dim wstr,str,url,start,over,city
City = request.querystring ("id")
Url= "http://cn.finance.yahoo.com/q?s=USDKRW=X&d=c"
Wstr=gethttppage (URL)
Start=newstring (WSTR, "last Transaction")
Over=newstring (WSTR, "buyer bid")
Body=mid (Wstr,start,over-start)

Start2=instr (Body, "<b>") +3
Over2=instr (Body, "</b>")
Body2=mid (BODY,START2,OVER2-START2)

Response.Write Body2
%>





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.