2012-05-05 39 views
0

我使用file_get_html来简单的HTML DOM,但我无法弄清楚如何获取网页的页面源代码! 有什么办法吗?我不是在谈论paintext!通过file_get_html获取网页的源代码

谢谢

+0

你不将取回一个网站的网址

源接受答案。为什么? – CyprUS

+0

即时通讯,他们不为我工作,我试图从另一个页面获取详细信息... err即时通讯soo累这f .. –

+0

你解决了你的prev问题http://stackoverflow.com/questions/10459649/get-page-discription-from-page-url-without-slowdowing-the-page-load/10459822#10459822 – CyprUS

回答

4

尝试file_get_contents。如果你想看到的源代码试试这个

echo htmlentities(file_get_contents("http://www.google.com")); 

http://php.net/manual/en/function.file-get-contents.php

为此,您可以使用curl也

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_URL, $file); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_REFERER, "http://www.google.com"); 
$result = curl_exec($ch); 
curl_close($ch); 
+0

它不会获取源intead它正在加载此页面当前页面内的网址!!!!! –

+0

@DilonPerera:它提取源代码,这就是为什么你在当前页面看到页面。 – Nauphal

+0

它就像一个魅力 – CyprUS