在PHP中设置用户代理参数简单HTML DOM解析器 [英] Seting User Agent param in PHP Simple HTML DOM Parser

查看:162
本文介绍了在PHP中设置用户代理参数简单HTML DOM解析器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

是否有任何方法可以包含用户代理字符串以及PHP发送的请求?通过查看代码,可以通过使用上下文流来实现,例如:

  $ context = stream_context_create(); 
stream_context_set_params($ context,array('user_agent'=>'UserAgent / 1.0'));
file_get_html('http://www.google.com/',0,$ context);

或者您也可以在 php.ini


Is there any way to include the user agent string along with the request send by PHP Simple HTML DOM Parser?

解决方案

By looking at the code it should be possible by using context streams, something like:

$context = stream_context_create();
stream_context_set_params($context, array('user_agent' => 'UserAgent/1.0'));
file_get_html('http://www.google.com/', 0, $context);

Alternatively you can also set default value in php.ini.

这篇关于在PHP中设置用户代理参数简单HTML DOM解析器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆