php to get contents of URL
JL gave me a php file which extracts information from URLs. It uses the php function file_get_contents(), which works only if the php.ini sets allow_url_fopen to On, which is not generally the case. So, I rewrote the code to use CURL library calls instead (three instances), and now at least I'm getting some kind of results back, so I think the code is probably working.
function get_entire_page($url) {
echo "<p>Following ".$url." </p>\n";
//$data = file_get_contents($url); // this call fails
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, $url);
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$data = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
echo "<div>\n";
echo $data . "\n";
echo "</div>\n";
}
The second problem is that the URL specified in the file JL gave me appears not to exist, as my call returns a 404 file not found page and when I put the URL into the url box of my browser I get a 404 file not found error. Contacted JL and CP in library (listed as contact) to enquire.