problem with file_get_contents
Posted: Tue May 12, 2009 8:31 pm
Hi I am using file_get_contents in this script.
it prints the follwing output. but I want the html webpage to be parsed.
Warning: file_get_contents(http://www.nlm.nih.gov/medlineplus/cancer.html") [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\wamp\www\websearch\searchdata.php on line 18
I am using wamp 2.0 and PHP 5.2.0. Please help
Code: Select all
<?php
$urlparam = $_GET['id'];
$html = file_get_contents("http://vsearch.nlm.nih.gov/vivisimo/cgi-bin/query-meta?input-form=simple&v%3Asources=medlineplus-bundle&v%3Aproject=medlineplus&binning-state=&query=".$urlparam."&x=67&y=9");
$regex = '/<span class=\"url\">(.+?)<\/span>/';
if (!preg_match_all($regex,$html,$matches))
return false;
$matches=$matches[1];
for ($i=0;$i<count($matches);$i++) {
$match=trim($matches[$i]);
$results[]= $match;
}
print_r(file_get_contents("http://".trim($results[0])."\"") );
?>Warning: file_get_contents(http://www.nlm.nih.gov/medlineplus/cancer.html") [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in C:\wamp\www\websearch\searchdata.php on line 18
Code: Select all