update README

This commit is contained in:
Jaeger 2017-09-29 15:05:33 +08:00
parent 59d48911fd
commit 1c54d63993

View File

@ -115,10 +115,18 @@ Array
//... //...
) )
``` ```
#### 编码转换
```php
// 输出编码:UTF-8,输入编码:GB2312
QueryList::get('https://top.etao.com')->encoding('UTF-8','GB2312')->find('a')->texts();
// 输出编码:UTF-8,输入编码:自动识别
QueryList::get('https://top.etao.com')->encoding('UTF-8')->find('a')->texts();
```
#### HTTP网络操作 #### HTTP网络操作
- 携带cookie登录新浪微博 - 携带cookie登录新浪微博
``` ```php
//采集新浪微博需要登录才能访问的页面 //采集新浪微博需要登录才能访问的页面
$ql = QueryList::get('http://weibo.com','param1=testvalue & params2=somevalue',[ $ql = QueryList::get('http://weibo.com','param1=testvalue & params2=somevalue',[
'headers' => [ 'headers' => [
@ -131,7 +139,7 @@ echo $ql->find('title')->text();
//输出: 我的首页 微博-随时随地发现新鲜事 //输出: 我的首页 微博-随时随地发现新鲜事
``` ```
- 使用Http代理 - 使用Http代理
``` ```php
$urlParams = ['param1' => 'testvalue','params2' => 'somevalue']; $urlParams = ['param1' => 'testvalue','params2' => 'somevalue'];
$opts = [ $opts = [
// 设置http代理 // 设置http代理
@ -152,7 +160,7 @@ $ql->get('http://httpbin.org/get',$urlParams,$opts);
``` ```
- 模拟登录 - 模拟登录
``` ```php
// 用post登录 // 用post登录
$ql = QueryList::post('http://xxxx.com/login',[ $ql = QueryList::post('http://xxxx.com/login',[
'username' => 'admin', 'username' => 'admin',
@ -165,7 +173,7 @@ $ql->get('http://xxx.com/admin/page');
#### Form表单操作 #### Form表单操作
模拟登陆GitHub 模拟登陆GitHub
``` ```php
// 获取QueryList实例 // 获取QueryList实例
$ql = QueryList::getInstance(); $ql = QueryList::getInstance();
//获取到登录表单 //获取到登录表单
@ -220,7 +228,7 @@ $ql->bind('myHttp',function ($url){
#### 插件使用 #### 插件使用
使用CURL多线程插件,多线程采集GitHub排行榜: 使用CURL多线程插件,多线程采集GitHub排行榜:
``` ```php
$ql = QueryList::use(CurlMulti::class); $ql = QueryList::use(CurlMulti::class);
$ql->curlMulti([ $ql->curlMulti([
'https://github.com/trending/php', 'https://github.com/trending/php',