修改直到curl 成功.
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"intimate"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/474420502/gcurl"
|
||||
|
||||
"github.com/474420502/hunter"
|
||||
)
|
||||
|
||||
@@ -30,13 +31,11 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
for {
|
||||
|
||||
source, err := store.Pop(string(intimate.TTOpenrecUser))
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return
|
||||
}
|
||||
|
||||
if source == nil {
|
||||
return
|
||||
if source == nil && err != nil {
|
||||
log.Println(err)
|
||||
time.Sleep(time.Second * 2)
|
||||
continue
|
||||
}
|
||||
|
||||
userSource := &intimate.Source{}
|
||||
@@ -50,32 +49,71 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
|
||||
source.SetOperator(int32(intimate.OperatorError))
|
||||
source.SetErrorMsg(sql.NullString{String: err.Error(), Valid: true})
|
||||
store.UpdateError(source, err)
|
||||
continue
|
||||
}
|
||||
|
||||
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"
|
||||
curl := gcurl.ParseRawCURL(scurl)
|
||||
supportersSession := curl.CreateSession()
|
||||
supportersSession.SetCookies(wf.GetParsedURL(), cookies)
|
||||
log.Println(curl.ParsedURL)
|
||||
workflow := curl.CreateWorkflow(supportersSession)
|
||||
for {
|
||||
|
||||
supportersQuery := workflow.GetQuery()
|
||||
|
||||
for _, cookie := range cookies {
|
||||
if cookie.Name == "uuid" {
|
||||
supportersQuery.Set("Uuid", cookie.Value)
|
||||
continue
|
||||
}
|
||||
|
||||
if cookie.Name == "token" {
|
||||
supportersQuery.Set("Token", cookie.Value)
|
||||
continue
|
||||
}
|
||||
|
||||
if cookie.Name == "random" {
|
||||
supportersQuery.Set("Random", cookie.Value)
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
supportersQuery.Set("identify_id", source.GetSource().String)
|
||||
|
||||
workflow.SetQuery(supportersQuery)
|
||||
log.Println(workflow.GetRawURL())
|
||||
resp, err := workflow.Execute()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
} else {
|
||||
log.Println(string(resp.Content()))
|
||||
}
|
||||
return
|
||||
}
|
||||
// cookies := cxt.Session().GetCookies(wf.GetParsedURL())
|
||||
|
||||
ext := make(map[string]interface{})
|
||||
|
||||
ext["user"] = string(resp.Content())
|
||||
|
||||
wf = cxt.Session().Get(userUrl + "/supporters")
|
||||
resp, err = wf.Execute()
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
source.SetOperator(int32(intimate.OperatorError))
|
||||
source.SetErrorMsg(sql.NullString{String: err.Error(), Valid: true})
|
||||
continue
|
||||
}
|
||||
ext["user_supporters"] = 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 {
|
||||
log.Println(err)
|
||||
source.SetOperator(int32(intimate.OperatorError))
|
||||
source.SetErrorMsg(sql.NullString{String: err.Error(), Valid: true})
|
||||
store.UpdateError(source, err)
|
||||
continue
|
||||
}
|
||||
ext["user_live"] = string(resp.Content())
|
||||
@@ -83,15 +121,19 @@ func (oer *OpenrecExtratorRanking) Execute(cxt *hunter.TaskContext) {
|
||||
extJsonBytes, err := json.Marshal(ext)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
source.SetOperator(int32(intimate.OperatorError))
|
||||
source.SetErrorMsg(sql.NullString{String: err.Error(), Valid: true})
|
||||
store.UpdateError(source, err)
|
||||
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