TODO: 解决编码问题
This commit is contained in:
@@ -29,8 +29,8 @@ func (or *OpenrecRankingTest) Execute(cxt *hunter.TaskContext) {
|
||||
t.Error("rank is error. result raw is ", result.Raw)
|
||||
}
|
||||
|
||||
if cxt.Workflow().GetQuery().Get("page") != "1" {
|
||||
t.Error("workflow page error")
|
||||
if cxt.Temporary().GetQuery().Get("page") != "1" {
|
||||
t.Error("Temporary page error")
|
||||
}
|
||||
// t.Error(string(resp.Content()))
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func (or *OpenrecRanking) Execute(cxt *hunter.TaskContext) {
|
||||
break
|
||||
}
|
||||
|
||||
wf := cxt.Workflow()
|
||||
wf := cxt.Temporary()
|
||||
|
||||
content := resp.Content()
|
||||
if len(content) <= 200 {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"intimate"
|
||||
"log"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/474420502/gcurl"
|
||||
"github.com/tidwall/gjson"
|
||||
|
||||
"github.com/474420502/hunter"
|
||||
)
|
||||
@@ -45,7 +48,7 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
|
||||
wf := cxt.Session().Get(userUrl)
|
||||
resp, err := wf.Execute()
|
||||
source.SetUpdateTime(time.Now())
|
||||
source.SetUpdateTime(sql.NullTime{Time: time.Now(), Valid: true})
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
@@ -55,16 +58,16 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
|
||||
cookies := cxt.Session().GetCookies(wf.GetParsedURL())
|
||||
|
||||
scurl := "curl 'https://www.openrec.tv/viewapp/api/v6/supporters?identify_id=sumomo_xqx&month=&Uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683&Token=46598c320408bd69ae3c63298f6f4a3a97354175&Random=AZVXNAAXQVMOSVWNDPIQ&page_number=1' -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' -H 'cookie: uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683;' --compressed"
|
||||
scurl := "https://www.openrec.tv/viewapp/api/v6/supporters?identify_id=sumomo_xqx&month=&Uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683&Token=46598c320408bd69ae3c63298f6f4a3a97354175&Random=AZVXNAAXQVMOSVWNDPIQ&page_number=1 -H 'accept: application/json, text/javascript, */*; q=0.01' -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' -H 'cookie: uuid=B96EE988-E3A2-4A44-A543-611A8B4BC683;' --compressed"
|
||||
curl := gcurl.ParseRawCURL(scurl)
|
||||
supportersSession := curl.CreateSession()
|
||||
|
||||
log.Println(curl.ParsedURL)
|
||||
workflow := curl.CreateWorkflow(supportersSession)
|
||||
supportersSession.SetCookies(workflow.GetParsedURL(), cookies)
|
||||
temporary := curl.CreateTemporary(supportersSession)
|
||||
supportersSession.SetCookies(temporary.GetParsedURL(), cookies)
|
||||
var supporters []string
|
||||
for {
|
||||
|
||||
supportersQuery := workflow.GetQuery()
|
||||
supportersQuery := temporary.GetQuery()
|
||||
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name == "uuid" {
|
||||
@@ -84,34 +87,37 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
}
|
||||
|
||||
supportersQuery.Set("identify_id", source.GetSource().String)
|
||||
temporary.SetQuery(supportersQuery)
|
||||
|
||||
workflow.SetQuery(supportersQuery)
|
||||
// workflow.AddCookies(cookies)
|
||||
log.Println(workflow.GetRawURL())
|
||||
log.Println(supportersSession.GetCookies(workflow.GetParsedURL()))
|
||||
resp, err := workflow.Execute()
|
||||
resp, err := temporary.Execute()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
log.Println(string(resp.Content()))
|
||||
}
|
||||
return
|
||||
}
|
||||
// cookies := cxt.Session().GetCookies(wf.GetParsedURL())
|
||||
supporterjson := gjson.ParseBytes(resp.Content())
|
||||
supporterdata := supporterjson.Get("data")
|
||||
if supporterdata.Type == gjson.Null {
|
||||
break
|
||||
}
|
||||
supporters = append(supporters, string(resp.Content()))
|
||||
|
||||
page := supportersQuery.Get("page_number")
|
||||
pageint, err := strconv.Atoi(page)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
break
|
||||
}
|
||||
pageint++
|
||||
page = strconv.Itoa(pageint)
|
||||
supportersQuery.Set("page_number", page)
|
||||
temporary.SetQuery(supportersQuery)
|
||||
}
|
||||
|
||||
// cookies := cxt.Session().GetCookies(wf.GetParsedURL())
|
||||
ext := make(map[string]interface{})
|
||||
|
||||
ext["supporters"] = supporters
|
||||
ext["user"] = string(resp.Content())
|
||||
|
||||
// wf = cxt.Session().Get(userUrl + "/supporters")
|
||||
// resp, err = wf.Execute()
|
||||
// if err != nil {
|
||||
// log.Println(err)
|
||||
// store.UpdateError(source, err)
|
||||
// continue
|
||||
// }
|
||||
// ext["user_supporters"] = string(resp.Content())
|
||||
|
||||
wf = cxt.Session().Get("https://www.openrec.tv/live/" + userid)
|
||||
resp, err = wf.Execute()
|
||||
if err != nil {
|
||||
@@ -128,15 +134,9 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
continue
|
||||
}
|
||||
|
||||
// buf := bytes.Buffer{}
|
||||
// encoder := gob.NewEncoder(&buf)
|
||||
// encoder.Encode(cookies)
|
||||
|
||||
// source.SetPassGob(sql.NullString{String: buf.String(), Valid: true})
|
||||
source.SetOperator(int32(intimate.OperatorOK))
|
||||
source.SetExt(string(extJsonBytes))
|
||||
store.Update(source)
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user