asp抓取网页内容<br /> &lt;% <br /> function getHTTPPage(url,cset) <br /> dim Http <br /> set Http=server.createobject(&quot;MSXML2.XMLHTTP&quot;) <br /> Http.open &quot;GET&quot;,url,false <br /> Http.send() <br /> if Http.readystate&lt;&gt;4 then exit function <br /> getHTTPPage=bytesToBSTR(Http.responseBody,cset) <br /> set http=nothing <br /> if err.number&lt;&gt;0 then err.Clear <br /> end function <br /> <br /> Function BytesToBstr(body,Cset) <br /> dim objstream <br /> set objstream = Server.CreateObject(&quot;adodb.stream&quot;) <br /> objstream.Type = 1 <br /> objstream.Mode =3 <br /> objstream.Open <br /> objstream.Write body <br /> objstream.Position = 0 <br /> objstream.Type = 2 <br /> objstream.Charset = Cset <br /> BytesToBstr = objstream.ReadText <br /> objstream.Close <br /> set objstream = nothing <br /> End Function <br /> <br /> response.write(getHTTPPage(&quot;http://www.baidu.com/&quot;,&quot;gb2312&quot;))<br /> %&gt;
返回顶部 留言