当前位置:网站首页>[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()
边栏推荐
猜你喜欢
随机推荐
关于tp的apache 的.htaccess文件
3.PHP数据类型、常量、字符串和运算符
PHP基金会三月新闻公告发布
1.初识PHP
ES6三点运算符、数组方法、字符串扩展方法
Function hoisting and variable hoisting
L1-039 古风排版(C)
稳定好用的短连接生成平台,支持API批量生成
uniapp | 开发中遇到的兼容性问题(待续)
SQL分类、DQL(数据查询语言)、以及相应SQL查询语句演示
TypeScript 错误 error TS2469、error TS2731 解决办法
针对简历上的问题
6.27面试集
客户评分控件
PHP 给图片添加全图水印
mysql阶段总结
uniapp | 使用npm update更新后编译报错问题
L1-020 帅到没朋友 (20分)
debian 10 nat and routing forwarding
微信小程序云开发之券码领取,怎么防止用户领取到相同的数据?









