Previosly I have been pulling in some page content via CURL from the BBC site using this code,
$c = curl_init('http://news.bbc.co.uk/sport1/hi/football/eng_conf/conference_north_table/default.stm');
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
$html = curl_exec ($c);
if (curl_error($c))
die(curl_error($c));
$startpos = strpos($html, '<table border="1" cellpadding="1" cellspacing="0" class="fulltable">');
$endpos = strpos($html, '<!-- E IINC -->');
$length = $endpos - $startpos;
$rest = substr($html, $startpos,$length);
$rest = str_replace("border=\"1\" cellpadding=\"1\" cellspacing=\"0\"","border=\"0\" cellpadding=\"0\" cellspacing=\"0\"", $rest);
$rest = str_replace('<tr><td colspan="15"><hr/></td></tr>',"", $rest);
$rest = str_replace('<tr>
<td colspan="15">
<div style="padding: 10px 0 0 0;"><img src=" http://newsimg.bbc.co.uk/sol/shared/img/tbl_spc.gif" height="2px" width="100%"></div>
</td>
</tr>
',"", $rest);
echo $rest;
curl_close($c);
Previously this was working fine using php 5.1.3 on an old server we have since migrated the site to a server running 5.4.8, however the above code is not working anymore, is there any reason for this? I cannot see any problem.
If I kill the script at $html
I get the following reponse,
LEAGUE TABLE
MOVED PERMANENTLY
The document has moved here.
However if I navigate to the URL through the browser I can view the page fine, so it obviously has not moved anywhere (backed up by the fact the Curl request was working before we migrated servers.