Created
July 18, 2018 04:37
-
-
Save kafleg/f54d8289ecf755e6ea575fff5ec4926d to your computer and use it in GitHub Desktop.
Crawl data from third party website
This file contains 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 | |
$username='username'; //username for fetching data | |
$password='password'; //password for login | |
$URL='https://example.com'; //Url of third party website | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,$URL); | |
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); | |
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); | |
$result=curl_exec ($ch); | |
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code | |
curl_close ($ch); | |
//var_dump($status_code); //developmeent code | |
// var_dump($result); //developmeent code | |
// $php_array = json_decode($result); //developmeent code | |
// var_dump($php_array); //developmeent code | |
//var_dump(json_decode($result, true)); //developmeent code | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment