修改直到curl 成功.
This commit is contained in:
@@ -1,35 +1,73 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"intimate"
|
||||
"bytes"
|
||||
"encoding/gob"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
"github.com/474420502/requests"
|
||||
)
|
||||
|
||||
func TestExtractor(t *testing.T) {
|
||||
collect := intimate.NewExtractorStore()
|
||||
store := intimate.NewSourceStore("source_openrec")
|
||||
source, err := store.Pop("openrec_user", 100)
|
||||
if source != nil {
|
||||
defer store.Restore(source)
|
||||
}
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
sdata := source.GetExt().([]byte)
|
||||
|
||||
if gjson.ValidBytes(sdata) {
|
||||
result := gjson.ParseBytes(sdata)
|
||||
m := result.Map()
|
||||
for key := range m {
|
||||
t.Error(key)
|
||||
ai := &intimate.CollectLog{}
|
||||
ai.SetAnchorId("123")
|
||||
collect.InsertCollectLog(ai)
|
||||
}
|
||||
} else {
|
||||
t.Error("data is not json:\n", string(sdata))
|
||||
}
|
||||
ses := requests.NewSession()
|
||||
wf := ses.Get("https://www.openrec.tv/user/Riowh/supporters")
|
||||
wf.Execute()
|
||||
|
||||
// t.Error(ses.GetCookies(wf.GetParsedURL()))
|
||||
|
||||
buf := bytes.Buffer{}
|
||||
encoder := gob.NewEncoder(&buf)
|
||||
encoder.Encode(ses.GetCookies(wf.GetParsedURL()))
|
||||
|
||||
var cookies []*http.Cookie
|
||||
decoder := gob.NewDecoder(&buf)
|
||||
t.Error(decoder.Decode(&cookies))
|
||||
t.Error(cookies)
|
||||
|
||||
// collect := intimate.NewExtractorStore()
|
||||
// store := intimate.NewSourceStore("source_openrec")
|
||||
// source, err := store.Pop(string(intimate.TTOpenrecRanking), 100)
|
||||
// if source != nil {
|
||||
// defer store.Restore(source)
|
||||
// }
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// sdata := source.GetExt().([]byte)
|
||||
|
||||
// if gjson.ValidBytes(sdata) {
|
||||
// result := gjson.ParseBytes(sdata)
|
||||
// m := result.Map()
|
||||
|
||||
// user := m["user"]
|
||||
|
||||
// ai := &intimate.CollectLog{}
|
||||
// extractor := hunter.NewExtractor([]byte(user.Str))
|
||||
// xp, err := extractor.XPathResult("//p[@class='c-global__user__count__row__right js-userCountFollowers']/text()")
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
// if !xp.NodeIter().Next() {
|
||||
// t.Error("不存在粉丝数")
|
||||
// }
|
||||
|
||||
// followers := strings.ReplaceAll(xp.String(), ",", "")
|
||||
|
||||
// followersInt, err := strconv.Atoi(followers)
|
||||
// if err != nil {
|
||||
// t.Error(err)
|
||||
// }
|
||||
|
||||
// ai.SetPlatform(string(intimate.Popenrec))
|
||||
// ai.SetFollowers(sql.NullInt32{Int32: int32(followersInt), Valid: true})
|
||||
// ai.SetAnchorId(source.GetSource().String)
|
||||
|
||||
// collect.InsertCollectLog(ai)
|
||||
|
||||
// } else {
|
||||
// t.Error("data is not json:\n", string(sdata))
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user