[campo/random-user-agent]随机伪造你的User-Agent

2022-03-23 奥古斯宏
一个随机生成User-Agent的库

有时候我们访问远程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

可以查看支持的所有的参数:

版权声明:本文由phpreturn.com(PHP武器库官网)原创和首发,所有权利归phpreturn(PHP武器库)所有,本站允许任何形式的转载/引用文章,但必须同时注明出处。

  • UserAgent::getDeviceTypes()
  • UserAgent::getAgentTypes()
  • UserAgent::getAgentNames()
  • UserAgent::getOSTypes()
  • UserAgent::getOSNames()


最近浏览
IP用户:34.64.*.*
2 天前 Googlebot
IP用户:34.64.*.*
3 天前 Googlebot
IP用户:39.165.*.*
3 天前 Go-http-client
IP用户:74.125.*.*
3 天前 Googlebot
IP用户:140.205.*.*
3 天前 Generic Bot
IP用户:34.64.*.*
3 天前 Googlebot
IP用户:52.167.*.*
4 天前 BingBot
IP用户:54.36.*.*
5 天前 aHrefs Bot
IP用户:60.188.*.*
6 天前 Generic Bot
IP用户:66.249.*.*
6 天前 Googlebot
IP用户:34.64.*.*
8 天前 Googlebot
IP用户:116.179.*.*
9 天前 Baidu Spider
累计浏览次数:959
评论
点击登录
phpreturn,PHP武器库,专注PHP领域的项目和资讯,收录和介绍PHP相关项目。
最近浏览 点击登录
IP用户:116.179.*.*
IP用户:223.93.*.*
IP用户:85.208.*.*
1 小时前 《PHP8.3发布》
累计浏览次数:102237
一周浏览次数:2943
今日浏览次数:49

本站所有权利归 phpreturn.com 所有

举报/反馈/投稿邮箱:phpreturn@ulthon.com

鲁ICP备19027671号-2