当前位置:网站首页>[campo/random-user-agent]随机伪造你的User-Agent
[campo/random-user-agent]随机伪造你的User-Agent
2022-08-02 03:24:00 【phpreturn】
有时候我们访问远程URL文件,需要指定User-Agent,这种情况不常见,但是如果你做的多了,你就会发现,有的文件只有使用浏览器才能打开,使用Curl或其他库却只能获取到403.
这时候我们需要指定一个User-Agent.
安装
composer require campo/random-user-agent使用
使用方式非常简单,只要最简单的调用即可:
echo \Campo\UserAgent::random(), "\n";指定一些User-Agent类型,比如操作系统或者设备类型:
echo \Campo\UserAgent::random([
'os_type' => 'Windows',
'device_type' => 'Mobile'
]), "\n";也可以使用同时穿多个类型:
echo \Campo\UserAgent::random([
'os_type' => ['Android', 'iOS'],
'device_type' => ['Mobile', 'Tablet']
]), "\n";支持的全部筛选如下:
agent_nameagent_typedevice_typeos_nameos_type
可以查看支持的所有的参数:
UserAgent::getDeviceTypes()UserAgent::getAgentTypes()UserAgent::getAgentNames()UserAgent::getOSTypes()UserAgent::getOSNames()
边栏推荐
猜你喜欢
随机推荐
js __proto__、prototype、constructor的关系
AES加密的各种蛋疼方式方式
ES6迭代器解释举例
Living to detect the Adaptive Normalized Representation Learning for GeneralizableFace Anti - Spoofing reading notes
关于tp的apache 的.htaccess文件
微信小程序九宫格抽奖和转盘抽奖的实现
meime module
面试总结 22/7/25 面试中的重点
第一次手撕代码,如何解出全排列问题
环形链表---------约瑟夫问题
钟表刻度线
由中序遍历和后序遍历得到前序遍历(树的遍历)
Common methods of js array deduplication
三元判断再三元判断
js basics
IP门禁:手把手教你用PHP实现一个IP防火墙
2.PHP变量、输出、EOF、条件语句
PHP 给图片添加全图水印
相对路径和绝对路径
解决MySQL创建子视图并查看的时候,字符集报错问题









