71 lines
1.7 KiB
Go
71 lines
1.7 KiB
Go
package proxy
|
|
|
|
import (
|
|
"bytes"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/sirupsen/logrus"
|
|
"gopkg.in/elazarl/goproxy.v1"
|
|
)
|
|
|
|
type Follower struct {
|
|
Extra struct {
|
|
FatalItemIds []any `json:"fatal_item_ids"`
|
|
Logid string `json:"logid"`
|
|
Now int64 `json:"now"`
|
|
} `json:"extra"`
|
|
Followers []struct {
|
|
AvatarThumb struct {
|
|
Height int `json:"height"`
|
|
URI string `json:"uri"`
|
|
URLList []string `json:"url_list"`
|
|
Width int `json:"width"`
|
|
} `json:"avatar_thumb"`
|
|
Nickname string `json:"nickname"`
|
|
SecUID string `json:"sec_uid"`
|
|
ShortID string `json:"short_id"`
|
|
UID string `json:"uid"`
|
|
UniqueID string `json:"unique_id"`
|
|
UniqueIDModifyTime int `json:"unique_id_modify_time"`
|
|
} `json:"followers"`
|
|
HasMore bool `json:"has_more"`
|
|
MyselfUserID string `json:"myself_user_id"`
|
|
Offset int `json:"offset"`
|
|
RecHasMore bool `json:"rec_has_more"`
|
|
StatusCode int `json:"status_code"`
|
|
StorePage string `json:"store_page"`
|
|
Total int `json:"total"`
|
|
VcdCount int `json:"vcd_count"`
|
|
}
|
|
|
|
func WithFollower() Option {
|
|
return func(p *Proxy) {
|
|
p.proxy.OnResponse().DoFunc(func(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response {
|
|
if resp.StatusCode != 200 {
|
|
return resp
|
|
}
|
|
|
|
if resp.Request.Host != "www.douyin.com" {
|
|
return resp
|
|
}
|
|
|
|
if resp.Request.URL.Path != "/aweme/v1/web/user/follower/list/" {
|
|
return resp
|
|
}
|
|
|
|
body, err := io.ReadAll(resp.Body)
|
|
if err != nil {
|
|
logrus.Error(err)
|
|
return resp
|
|
}
|
|
resp.Body.Close()
|
|
resp.Body = io.NopCloser(bytes.NewReader(body))
|
|
|
|
go p.processFollowers(body)
|
|
|
|
return resp
|
|
})
|
|
}
|
|
}
|