简体   繁体   中英

PHP file_get_contents / CURL not returning full page

I'm geting some strange behaviour trying to pull 3rd party file contents using CURL or file_get_contents, pasrt of the page is read, but it stops at a random position... no error though (timeout etc).

Probably easiest to see if I give the full example!:

Using the following very bsic script to read a full URL and return the contents works just fine, with the full content of the page (less some external css etc) in a mater of a second or two:

<?php    
set_time_limit(180);
$page = file_get_contents('http://www.fantasyleague.com/Classic/Stats/playerlist.aspx?dpt=3');
echo $page;
?>

However, if we change to

<?php    
set_time_limit(180);
$page = file_get_contents('http://www.fantasyleague.com/Classic/Stats/playerlist.aspx?dpt=4');
echo $page;
?>

it takes ages to run, and eventually returns part of the page, but not all. It's not consistent, but it generally ends with either "A Westwood AV 3.6 12" or "show", a bit further up the page.

If you look at the two URLs, you can see they are basically prettu much the same. And this behaviour has onyl just started occuring, up until a day or two ago, both worked fine.

Any ideas? I can provide any further info I've missed out!

Edit:

An example of where the file finishes... original file contains:

<div class="right">
    <a id="Playerlist_help_button" class="button left" href="#"><div>Show help</div></a>
    <a id="Playerlist_filters_button" class="button left" href="#"><div>Show filters</div></a>
    <a class="button left" href="PlayerListPrintable.aspx" target="_blank"><div>Printable Version</div></a>
    <br class="clear" />
</div>

but the retrieved data stops at:

<div class="right">
    <a id="Playerlist_help_button" class="button left" href="#"><div>Show help</div></a>
    <a id="Playerlist_filters_button" class="button left" href="#"><div>Show 

or the other place it often fails is:

        <td><div class="chilli normal" /></td>


        <td>12</td>


        <td>0</td>

which becomes:

        <td><div class="chilli normal" /></td>


        <td>12</td>

通过file_get_contents或curl只有一次你可以得到html源而不是所有组件

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM