Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP获取网页内容_Php_Parsing_Dom_Html Parsing_Simple Html Dom - Fatal编程技术网

PHP获取网页内容

PHP获取网页内容,php,parsing,dom,html-parsing,simple-html-dom,Php,Parsing,Dom,Html Parsing,Simple 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/st

因此,我使用的是获取网页的内容。在我知道我所做的是正确的之后,我仍然得到了一个错误,那就是什么也找不到

下面是我用来观察是否有什么东西被抓到的方法:

<?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似乎没有被工具刮掉。。。为什么?

我测试了你的问题,效果很好。您必须检查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 />";

simple\u php\u dom.php
包含:

define('MAX_FILE_SIZE', 600000);
...
if (empty($contents) || strlen($contents) > MAX_FILE_SIZE)
{
    return false;
}

第二页超过672000字节,因此此大小检查失败。增加该常数,您应该就可以了。

您调用的是
file\u get\u contents
,而不是
file\u get\u html
。它不是PHP函数。您应该添加该文件以验证该常量定义('MAX\u file\u SIZE',600000);如果这个常量存在于简单dom库中,它是他加载的简单HTML dom解析器库的一部分,那么它将阻止您的请求。谢谢。这么多。也谢谢@Sundar。