简单的DOM file_get_html不返回任何内容

Leo*_*eon 2 php simple-html-dom web-scraping

我正在尝试从某些网站抓取数据。对于多个网站,一切似乎都很好,但是对于一个网站,似乎无法获取任何HTML。这是我的代码:

<?php include_once('simple_html_dom.php');

$html = file_get_html('https://www.magiccardmarket.eu/?mainPage=showSearchResult&searchFor=' . $_POST['data']);

echo $html; ?>
Run Code Online (Sandbox Code Playgroud)

我正在使用ajax来获取数据。当我在js中记录返回值时,它完全为空。

可能是由于该网站在https上运行?如果是这样,是否有任何解决方法?(我尝试将网址更改为http,但得到的结果相同)

更新:

如果我var_dump $ html变量,我会得到bool(false)。

我的PHP错误日志说:

[2014年2月27日22:20:50欧洲/阿姆斯特丹] PHP警告:file_get_contents(http://www.magiccardmarket.eu/?mainPage=showSearchResult&searchFor=tarmogoyf):打开流失败:HTTP请求失败!第75行的/Users/leondewit/PhpstormProjects/Magic/stores/simple_html_dom.php中禁止HTTP / 1.0 403

pgu*_*rio 5

它是您的用户代理,默认情况下file_get_contents不发送任何内容,因此:

$url = 'http://www.magiccardmarket.eu/?mainPage=showSearchResult&searchFor=tarmogoyf';
$context = stream_context_create(array('http' => array('header' => 'User-Agent: Mozilla compatible')));
$response = file_get_contents($url, false, $context);
$html = str_get_html($response);
echo $html;
Run Code Online (Sandbox Code Playgroud)