package main import ( "fmt" "io/ioutil" "os" "testing" "github.com/474420502/gcurl" ) func CrawlContent(args ...interface{}) []byte { nimoapi := `curl 'https://api.nimo.tv/oversea/nimo/api/v2/liveRoom/liveRoomPage-%d-30-/HK/1028/1000' \ -H 'authority: api.nimo.tv' \ -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36' \ -H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary3bCA1lzvhj4kBR4Q' \ -H 'accept: */*' \ -H 'origin: https://www.nimo.tv' \ -H 'sec-fetch-site: same-site' \ -H 'sec-fetch-mode: cors' \ -H 'sec-fetch-dest: empty' \ -H 'referer: https://www.nimo.tv/lives' \ -H 'accept-language: zh-CN,zh;q=0.9' \ --data-binary $'------WebKitFormBoundary3bCA1lzvhj4kBR4Q\r\nContent-Disposition: form-data; name="keyType"\r\n\r\n0\r\n------WebKitFormBoundary3bCA1lzvhj4kBR4Q\r\nContent-Disposition: form-data; name="body"\r\n\r\n{"deviceType":7,"requestSource":"WEB","iNetType":5}\r\n------WebKitFormBoundary3bCA1lzvhj4kBR4Q--\r\n' \ --compressed` curl := gcurl.Parse(fmt.Sprintf(nimoapi, 1)) tp := curl.CreateTemporary(nil) resp, err := tp.Execute() if err != nil { panic(err) } return resp.Content() } func openTestFile(...interface{}) []byte { f, err := os.Open("../../../testfile/nimo1.json") if err != nil { panic(err) } data, err := ioutil.ReadAll(f) if err != nil { panic(err) } return data } var Crawl func(...interface{}) []byte func Test(t *testing.T) { Execute() }