Created
November 30, 2013 11:46
-
-
Save anytizer/7718039 to your computer and use it in GitHub Desktop.
scrap web contents
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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