在PHP Simple HTML DOM Parser中设置用户代理参数

Mit*_*ran 0 html php parsing dom facebook

是否有任何方法可以将用户代理字符串与PHP Simple HTML DOM Parser发送的请求一起包含在内?

Mit*_*ran 10

感谢MichalČihař,你是对的我只是在simple_html_dom类的load_file()函数中进行了一些更改并且它工作正常

// load html from file
    function load_file() {
        $args = func_get_args();
        // Added by Mithun
        $opts = array(
            'http'=>array(
                'method'=>"GET",
                'header'=>"Accept-language: en\r\n" .
                "User-Agent:    Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.6) Gecko/20091201 Firefox/3.5.6\r\n".
                "Cookie: foo=bar\r\n"
            )
        );
        $context = stream_context_create($opts);
        $args[1] = FALSE;
        $args[2] = $context;
        // End Mithun
        $this->load(call_user_func_array('file_get_contents', $args), true);
    }
Run Code Online (Sandbox Code Playgroud)