日期:2014-05-16  浏览次数:20287 次

请问如何获得网页的源代码?
我要在我的网页中获得:http:www.baidu.com/这个网页的源代码来进行分析,如何从网上获得他的源代码?

------解决方案--------------------
set x=server.createObject("Microsoft.XMLHTTP")
x.open "get","http://www.baidu.com",false
x.send
dim str
str = x.responseText
------解决方案--------------------
function bin2str(bin)
dim tmp,ustr
tmp=""
for i=1 to LenB(bin)-1
ustr=AscB(MidB(bin,i,1))
if ustr>127 then
i=i+1
tmp=tmp&chr(ustr*256+AscB(MidB(bin,i,1)))
else
tmp=tmp&chr(ustr)
end if
next
bin2str=tmp
end function

set x=server.createObject("Microsoft.XMLHTTP")
x.open "get","http://www.webjx.com",false
x.send
str=bin2str(x.responseBody)
response.write "<xmp>"&str&"</xmp>"
set x=nothing 
这样可以获取中文

------解决方案--------------------
看你要用什么方式了,用ASP,PHP,JSP,ASP。NET,都可以。这里给你PHP的代码吧。
@$fp = fsockopen("hk.finance.yahoo.com",80, $errno, $errstr,60); 
if (!$fp) { 
//echo "$errstr ($errno)<br/>\n"; 
} else { 
$out = "GET /q?s=0348.HK HTTP/1.1\r\n"; 
$out .= "Host: hk.finance.yahoo.com \r\n"; 
$out .= "Connection: Close \r\n\r\n"; 
 
@fputs($fp, $out); 
while (!feof($fp)) { 
$line = fgets ($fp, 1024);
echo $line."<br>";
break; 


fclose($fp);