...
| Code Block |
|---|
// custom_file_get_contents by Chun Kang (ck@ckii.com)
function custom_file_get_contents( $url, $custom_http_user_agent="Mozilla/5.0 (CentOS; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36 (ck)")
{
// define options
$options = array([
'http'=>array(> [ // it must be http, not https
'method'=>"GET",
'header'=>
'header'=> "User-Agent: {$custom_http$http_user_agent}\r\n" .
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9\r\n" .]
"Accept-Language: en-US\r\n" .
"Connection: keep-alive\r\n"
)
)];
$context = stream_context_create($options);
$buff=@file_get_contents( $url, false, $context);
return $buff;
}
echo custom_file_get_contents( "http://yahoo.com");
echo "\n\n"
echo custom_file_get_contents( "https://yahoo.com"); |
...