我希望得到https://06fazmusic.com/的内容,但file_get_content不起作用。
$context = stream_context_create(array(
'http' => array(
'method' => "GET",
'follow_location' => false,
'header' => "Accept-Language: en-US,en;q=0.8rn" .
"Accept-Encoding: gzip,deflate,sdchrn" .
"Accept-Charset:UTF-8,*;q=0.5rn" .
"Accept-Language:en-US,en;q=0.8" .
"Cache-Control:max-age=0" .
"User-Agent:Mozilla/5.0 (Windows NT 10.0; Win64; x64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36"
)
));
$post_url='https://06fazmusic.com/omid-called-namaze-eshgh/';
$array = get_headers($post_url);
echo file_get_contents($post_url, false, $context);
答案 0 :(得分:0)
我没有使用file_get_contents()。我使用Curl类型来获取该页面的代码是:
function curl_get_contents($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
echo curl_get_contents($post_url);