idetinkin / php-curl-parser
将curl命令转换成PHP Curl对象或Curl资源。
dev-master
2020-08-24 16:08 UTC
Requires
- php: >=5.6.0
- clue/arguments: ^2.0
- php-curl-class/php-curl-class: ^8.8
Requires (Dev)
- phpunit/phpunit: ^7.0 || ^6.0 || ^5.7 || ^4.8.35
This package is auto-updated.
Last update: 2024-09-25 01:38:57 UTC
README
从curl命令生成Curl对象的最简单方法,该命令是为命令行设计的。
使用示例
如果你想要模拟第三方网站上的用户操作(只有在用户信任你的服务,或者你是用户本身的情况下才能接受)
- 打开你想要模拟用户操作的网站
- 按Control+Shift+J打开DevTools
- 点击网络标签页。网络面板将打开
- 点击文档标签页
- 刷新页面
- 右键点击请求并选择复制 -> 复制为cURL
- 将剪贴板中的文本传递给PHP脚本
PHP脚本示例
$curlCommand = "curl 'https://www.google.com/?gws_rd=ssl' \ -H 'authority: www.google.com' \ -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36' \ --compressed"; $curl = (new \curlParser\Parser($curlCommand))->getCurlObject(); $html = $curl->exec();
支持的属性
- -H 或 --header
- --compressedx