brunodebarros/http-request
Composer 安装命令:
composer require brunodebarros/http-request
包简介
A web crawler, built to be easily dropped into PHP applications, which behaves just like a regular web browser, interpreting location redirects and storing cookies automatically.
README 文档
README
HTTP Request 1.0
HTTP Request is a web crawler which behaves just like a regular web browser, interpreting location redirects and storing cookies automatically.
Features
- HTTP/HTTPS Requests
- Automatic cookie and redirect handling
- GET/POST Requests
How to use it
Install with Composer
Add brunodebarros/http-request to the contents of your composer.json:
{
"require": {
"brunodebarros/http-request": "dev-master"
}
}
Then use it!
$http = new HTTP_Request();
$content = $http->request($url, $mode, $data, $save_to_file);
$url is the URL to access. HTTP Request supports HTTPS requests just as easily as HTTP, as long as you have OpenSSL enabled on your PHP server.
$mode is either GET or POST. If empty, a GET request will be made.
$data is an array of data to pass via GET or POST. Couldn't be simpler. If empty, no extra data will be sent in the request.
$save_to_file is the filename of the file where you want the output to be stored. If empty, the output will not be stored anywhere.
Examples
$http = new HTTP_Request();
# Make a simple GET Request:
$content = $http->request('http://website.com');
# Make a POST request to a HTTPS website with some data:
$content = $http->request('https://website.com/login', 'POST', array('user' => 'myusername', 'pass' => 'mypassword'));
# Make a simple GET Request and store it in a file:
$http->request('http://website.com', 'GET', array(), 'contents_of_website_dot_com.txt')
Why automatic cookie handling is awesome
The best part about HTTP Request is that it will automatically handle location redirects and cookies. So if you POST your login details to a website's login page, and then access another page on that website, the website will believe that you are logged in, because HTTP Request will have kept the cookies. This way, you can build truly human-like web crawlers that can easily perform pretty much any action a human can.
$http = new HTTP_Request();
# Login to website.com
$content = $http->request('https://website.com/login', 'POST', array('user' => 'myusername', 'pass' => 'mypassword'));
# Access restricted page (because of cookie handling, you will be logged in when you request this page, without any effort on your part)
$http->request('http://website.com/page-for-logged-in-users-only');
What's coming.
I intend to make HTTP Request a whole lot more powerful. Here are some ideas I have:
- Enhanced cookie handling (delete cookies when the server sends a request to delete the cookie, store cookies in files for future visits, etc.)
- Enhanced redirect interpretation (make it work with HTML meta redirects, and even JavaScript redirects)
- Chunk downloads to enable downloading very big files without going over PHP's memory_limit.
- If you have any ideas, create an issue. If you create an issue, I'll do everything I can to resolve it.
Suggestions, questions and complaints.
If you've got any suggestions, questions, or anything you don't like about HTTP Request, create an issue. I'd really appreciate your feedback. Feel free to fork this project, if you want to contribute to it.
brunodebarros/http-request 适用场景与选型建议
brunodebarros/http-request 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 207 次下载、GitHub Stars 达 9, 最近一次更新时间为 2013 年 07 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「http」 「crawler」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 brunodebarros/http-request 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 brunodebarros/http-request 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 brunodebarros/http-request 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight, dependency free PHP class that acts as wrapper for Crawlbase API
repository php library
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
http客户端
Easily add Excepct-CT header to your project
统计信息
- 总下载量: 207
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2013-07-24