Skip to content

Instantly share code, notes, and snippets.

@taisang1996
Created February 15, 2017 14:26
Show Gist options
  • Save taisang1996/a58d751215a164162491060b2ef9d7d8 to your computer and use it in GitHub Desktop.
Save taisang1996/a58d751215a164162491060b2ef9d7d8 to your computer and use it in GitHub Desktop.
curl phimmoi.net
<?php
function fetchSource($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = array();
$headers[] = "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
return $result;
}
$url = $_REQUEST['url'];
print_r(fetchSource($url));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment