【发布时间】:2015-03-05 17:51:35
【问题描述】:
我正在尝试使用 PHP simplehtmldom 库获取该网站的内容。
http://www.immigration.govt.nz/migrant/stream/work/workingholiday/czechwhs.htm"
它不起作用,所以我尝试使用 CURL:
function curl_get_file_contents($URL)
{
$c = curl_init();
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_URL, $URL);
$contents = curl_exec($c);
curl_close($c);
if ($contents) return $contents;
else return FALSE;
}
但总是只响应一些 JS 代码和内容:
<noscript>Please enable JavaScript to view the page content.</noscript>
有没有可能使用 PHP 来解决这个问题?在这种情况下我必须使用 PHP,所以我需要模拟基于 JS 的浏览器。
非常感谢您的任何建议。
【问题讨论】:
标签: javascript php curl web-scraping noscript