Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created November 30, 2013 11:46
Show Gist options
  • Select an option

  • Save anytizer/7718039 to your computer and use it in GitHub Desktop.

Select an option

Save anytizer/7718039 to your computer and use it in GitHub Desktop.
scrap web contents
<?php
/**
* Retrieves a web content from given URL
* @todo Apply best scapper method among curl, post, file_get_contents, url fopen
* @see methods used in API engines as well
*/
private function web_contents($url = '')
{
$options = array(
'http'=>array(
'method' => 'GET',
'header' => 'Accept-language: en',
'timeout' => 120,
'ignore_errors' => true,
)
);
$url_context = stream_context_create($options);
$fc = file_get_contents($url, false, $url_context);
return $fc;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment