Skip to content

Instantly share code, notes, and snippets.

@kafleg
Created July 18, 2018 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kafleg/f54d8289ecf755e6ea575fff5ec4926d to your computer and use it in GitHub Desktop.
Save kafleg/f54d8289ecf755e6ea575fff5ec4926d to your computer and use it in GitHub Desktop.
Crawl data from third party website
<?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