我使用file_get_html来简化html DOM,但我无法弄清楚如何获取URL的页面源代码!有什么办法吗?我不是在谈论痛苦文本!
谢谢
尝试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);