所以我使用PHP简单的HTML DOM解析器来获取网页的内容。当我知道我所做的是正确的,我仍然得到错误,没有任何东西可以找到。
下面是我用来查看是否有东西被捕获的代码:
<?php
include_once('simple_html_dom.php');
error_reporting(E_ALL);
ini_set('display_errors', '1');
$first_url = "http://www.transfermarkt.co.uk/en/chinese-super-league/startseite/wettbewerb_CSL.html"; // works
$html = file_get_html($first_url);
echo "<textarea>Output'n==========='n $html</textarea><br /><br />";
$second_url = "http://www.transfermarkt.co.uk/en/chinese-super-league/torschuetzen/wettbewerb_CSL.html"; // does not work?
$html = file_get_html($second_url);
echo "<textarea>Output'n==========='n $html</textarea><br />";
?>
没有错误。第二个文本区域没有任何内容。第二个URL似乎没有被工具刮掉…为什么?
simple_php_dom.php
包含:
define('MAX_FILE_SIZE', 600000);
...
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
return false;
}
第二页超过672000字节,所以这个大小检查失败。增大这个常数,应该没问题
我测试了你的问题,它工作正常。你必须检查php内存限制,这可能是问题
增加PHP内存限制并重试
<?php
//use this to increase memory limit
ini_set('memory_limit', '200M');
$second_url = "http://www.transfermarkt.co.uk/en/chinese-super-league/torschuetzen/wettbewerb_CSL.html"; // does not work?
$html = file_get_contents($second_url);
echo "<textarea>Output'n==========='n $html</textarea><br />";