Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 文件\u获取\u内容不适用于特殊站点_Php_Web_File Get Contents - Fatal编程技术网

Php 文件\u获取\u内容不适用于特殊站点

Php 文件\u获取\u内容不适用于特殊站点,php,web,file-get-contents,Php,Web,File Get Contents,我想获取文件的内容,但无法获取文件内容 $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" .

我想获取文件的内容,但无法获取文件内容

$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);  

我没有使用文件获取内容。我使用了Curl type来获取页面ex代码:

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);
它正在工作,输出屏幕截图为:

不工作意味着什么?请检查此代码。我无法获取此网站@Kerbholz的内容。请将“不工作”翻译为有意义的信息。它正在工作。。。从技术上讲是的,但访问被拒绝,所以当我尝试他的代码时,您无法获得真正的内容。它会抛出此错误文件\u get\u contentshttps://www.06fazmusic.com/omid-called-namaze-eshgh/: 无法打开流:HTTP请求失败!HTTP/1.1403被禁止,所以我使用Curl@B001我怎样才能得到这个网站?它阻止了机器人,我无法访问此网站的详细信息