Skip to content

Commit

Permalink
Add: 更新 readme.md 和 proxy test
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNullPoint committed Apr 30, 2020
1 parent 9a12f09 commit d5ada34
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 4 deletions.
35 changes: 31 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ NAME:
A simple tool to get somebody's weibo data - A new cli application
USAGE:
weint-v0.0.1-linux-amd64 [global options] command [command options] [arguments...]
weint-v0.0.2-linux-amd64 [global options] command [command options] [arguments...]
VERSION:
0.0.1
0.0.2
COMMANDS:
help, h Shows a list of commands or help for one command
Expand All @@ -34,7 +34,7 @@ GLOBAL OPTIONS:
--info, -i set to get user's profile (default: false)
--weibo, -w set to get user's weibo list (default: false)
--quick, -q set to use quick mode, best practice is to use a proxy pool when set this flag (default: false)
--proxy value, -p value set proxy[暂不支持]
--proxy value, -p value set proxy
--out value, -o value set output type, csv/json/db/elastic
--file value, -f value set output filename
--elastic value, -e value set elastic search address (default: 127.0.0.1:9200)
Expand Down Expand Up @@ -86,6 +86,12 @@ $ weint -u 用户id -w -o db -f output.db
$ weint -u 用户id -w -o elastic -e 127.0.0.1:9200
```
- 指定代理,支持 http 和 https
```shell
$ weint -u 用户id -p http://127.0.0.1:1080
```
- 快速采集模式(不推荐)
```shell
Expand Down Expand Up @@ -170,11 +176,32 @@ if err := spider.Run(); err != nil {
}
```
- 设置代理
```go
spider := weint.NewSpider()
uri := url.URL{}
proxy, _ := uri.Parse("http://127.0.0.1:1080")
spider.Client(&http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxy),
},
})
spider.Type(weint.TYPE_INFO)
spider.Type(weint.TYPE_WEIBO)
if err := spider.Run(); err != nil {
t.Error(err)
}
```
## TODO
- [ ] 获取指定用户粉丝和关注者
- [ ] 支持限制返回
- [ ] 支持代理
- [x] 支持代理
- [ ] 增加 godoc
## Inspired By
Expand Down
22 changes: 22 additions & 0 deletions test/spider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package test

import (
"github.com/MrNullPoint/weint"
"net/http"
"net/url"
"testing"
)

Expand All @@ -18,3 +20,23 @@ func TestSpiderOut(t *testing.T) {
t.Error(err)
}
}

func TestSpiderClient(t *testing.T) {
spider := weint.NewSpider()

uri := url.URL{}
proxy, _ := uri.Parse("http://127.0.0.1:1080")

spider.Client(&http.Client{
Transport: &http.Transport{
Proxy: http.ProxyURL(proxy),
},
})

spider.Type(weint.TYPE_INFO)
spider.Type(weint.TYPE_WEIBO)

if err := spider.Run(); err != nil {
t.Error(err)
}
}

0 comments on commit d5ada34

Please sign in to comment.