Scraping Error

Status
Not open for further replies.

Falian

Banned
Nov 2, 2007
1,317
46
0
xrumerblast.org
Hey everyone,

I've been working on creating a scraper script and I'm consistently getting the same bugs. After attempting to troubleshoot myself, I went online and found out what the errors usually mean.

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/toiletch/public_html/49ercru.com/Scraper.php on line 14

Warning: file_get_contents(https://siteexplorer.search.yahoo.com/search?p=$url) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/toiletch/public_html/49ercru.com/Scraper.php on line 14
array(0) { } Array

Apparently this has something to do with the php config settings on the server/hosting I have. I have hosting with ZenSix and I am wondering what the most appropriate method to fix these bugs is. Thanks.

Nick
 


Hey everyone,

I've been working on creating a scraper script and I'm consistently getting the same bugs. After attempting to troubleshoot myself, I went online and found out what the errors usually mean.

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /home/toiletch/public_html/49ercru.com/Scraper.php on line 14

Warning: file_get_contents(https://siteexplorer.search.yahoo.com/search?p=$url) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /home/toiletch/public_html/49ercru.com/Scraper.php on line 14
array(0) { } Array

Apparently this has something to do with the php config settings on the server/hosting I have. I have hosting with ZenSix and I am wondering what the most appropriate method to fix these bugs is. Thanks.

Nick

PHP: cURL - Manual
PHP: fopen - Manual

GL && posted in wrong section by the wya
 
file_get_contents is disabled ... this is pretty common.

try this instead

PHP:
$url = 'https://siteexplorer.search.yahoo.com/search?p=' . $url ;
$scrape = file_get_the_contents($url) ;

function file_get_the_contents($url) {
  $ch = curl_init();
  $timeout = 10; // set to zero for no timeout
  curl_setopt ($ch, CURLOPT_URL, $url);
  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  $file_contents = curl_exec($ch);
  curl_close($ch);
  return $file_contents;
}
This just uses curl instead of the native function file_get_content and it's pretty easy to remember (just add the word "the").

Also another thing to check out is you've got $url in the actual url. I'd wager that was a variable that didn't get parsed (which is why I added the top line in the above example) ... if you're using single quotes ('), you can't stick a variable inside. Use double quotes (") instead or just build the url on a separate line.

... I also wouldn't post your direct path on public forums /path/to/dir/scrape.php works just fine since absolute paths are not important when troubleshooting

Hey everyone,

I've been working on creating a scraper script and I'm consistently getting the same bugs. After attempting to troubleshoot myself, I went online and found out what the errors usually mean.

Warning: file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration in /path/to/dir/Scraper.php on line 14

Warning: file_get_contents(https://siteexplorer.search.yahoo.com/search?p=$url) [function.file-get-contents]: failed to open stream: no suitable wrapper could be found in /path/to/dir/Scraper.php on line 14
array(0) { } Array

Apparently this has something to do with the php config settings on the server/hosting I have. I have hosting with ZenSix and I am wondering what the most appropriate method to fix these bugs is. Thanks.

Nick
 
Status
Not open for further replies.