Add header request header when php file_get_content gets resources

<?php
    $context_options = array(
        'http' =>
            array(
                'method' => "GET",
                'header' => "User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\r\nReferer:http://www.zhuyanjun.cn/\r\n",
                'timeout' => 120,
            )
    );

    $context = stream_context_create($context_options);
    $html = file_get_contents('https://www.demo.com/',FALSE,$context);

 

Guess you like

Origin blog.csdn.net/JineD/article/details/112297375