chromeworker_client/client_test.go

37 lines
1.0 KiB
Go
Raw Normal View History

2020-11-23 08:15:19 +00:00
package cwclient
import (
"encoding/json"
"log"
"net/http"
"testing"
)
func TestPort(t *testing.T) {
cli := New("http://localhost:7123")
2020-11-23 10:49:37 +00:00
ltest := cli.Register("test", func(cxt *CallbackContext) {
if cxt.Error != nil {
log.Println("error:", cxt.Error)
} else {
log.Println(cxt.TaskID, cxt.Content, cxt.Carry)
}
})
2020-11-25 04:25:19 +00:00
2020-11-23 10:49:37 +00:00
ltest.SetContentConditionFromFile("example.js")
cli.Connect()
2020-11-25 04:25:19 +00:00
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser", nil))
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/yanngu?lang=en&deviceType=browser", "213"))
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/rip113?lang=en&deviceType=browser"))
// log.Println(ltest.Open("https://playerduo.com/api/playerDuo-service-v2/yanngu?lang=en&deviceType=browser"))
2020-11-25 04:25:19 +00:00
http.ListenAndServe(":4233", nil)
}
func TestChrome(t *testing.T) {
var a = make(map[string]interface{})
a["as"] = 123
data, _ := json.Marshal(a["as"])
log.Println(string(data), a["as"])
}