当前位置:网站首页>[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_name
agent_type
device_type
os_name
os_type
可以查看支持的所有的参数:
UserAgent::getDeviceTypes()
UserAgent::getAgentTypes()
UserAgent::getAgentNames()
UserAgent::getOSTypes()
UserAgent::getOSNames()
边栏推荐
猜你喜欢
随机推荐
PHP基金会三月新闻公告发布
meime模块
解决uni-app 打包H5网站 下载图片问题
微信小程序云开发之模糊搜索
如何查看一个现有的keil工程之前由什么版本的keil IDE编译
1.10今日学习
微信小程序云开发之券码领取,怎么防止用户领取到相同的数据?
1.13 学习JS
meime module
require modular syntax
我的小笔记 =》其他东东
线程池(线程池介绍与使用)
Error in render: “TypeError: Cannot read properties of null (reading ‘0‘)“ 报错解决方案
查询数据库中所有表的索引,并且解析成sql
简单黑马头条项目
L1-039 古风排版(C)
第一篇博客
uniapp | 官方提供的map组件使用问题
js takes the value of a feature at a certain position in the string, such as Huawei=> Huawei
14.JS语句和注释,变量和数据类型