Copy Code code as follows:
Url= "http://www.csdn.net/"
Wstr=gethttppage (URL)
Start=newstring (WSTR, "Resource selection <!--download-->")
Over=newstring (Wstr, "<div class=" "Friendlink" ">")
Body=mid (wstr,200,500)
Response.Write Body
Function gethttppage (URL)
Dim objxml
Set Objxml=createobject ("MSXML2. XMLHTTP ")" Definition
Objxml.open "Get", Url,false ' open
Objxml.send () ' Send
If Objxml.readystate<>4 then ' determines if the document has been parsed to make the client accept the return message
Exit function
End If
Gethttppage=bbytestobstr (objxml.responsebody) ' returns information, with function definition encoding
Set Objxml=nothing ' Off
If Err.number<>0 then err. Clear
End Function
Function newstring (WSTR,STRNG)
Newstring=instr (LCase (WSTR), LCase (STRNG))
If Newstring<=0 then Newstring=len (WSTR)
End Function
Function Bbytestobstr (body)
Dim objstream
Set objstream = CreateObject ("ADODB.stream")
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "gb2312"
' Convert the original default UTF-8 encoding to GB2312 encoding, otherwise directly using the XMLHTTP to invoke the page with Chinese characters will be garbled
Bbytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function
Function Bytestobstr (body)
Dim objstream
Set objstream = CreateObject ("ADODB.stream")
Objstream. Type = 1
Objstream. Mode =3
Objstream. Open
Objstream. Write body
Objstream. Position = 0
Objstream. Type = 2
Objstream. Charset = "Utf-8"
' Convert the original default UTF-8 encoding to GB2312 encoding, otherwise directly using the XMLHTTP to invoke the page with Chinese characters will be garbled
Bytestobstr = objstream. ReadText
Objstream. Close
Set objstream = Nothing
End Function