CopyCode The Code is 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' is used to determine whether the document has been parsed to receive the returned message from the client.
Exit Function
End if
Gethttppage = bbytestobstr (objxml. responsebody) 'returns information and uses function-defined encoding.
Set objxml = nothing 'disabled
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 the web page with Chinese characters will be garbled directly by calling XMLHTTP
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, the webpage with Chinese characters will be garbled by calling XMLHTTP directly
bytestobstr = objstream. readtext
objstream. close
set objstream = nothing
end function