Exemple #1
0
func Post(url, bodyStr dna.String) (*http.Result, error) {
	mutex.Lock()
	http.DefaulHeader = Header
	http.DefaulHeader.Set("Cookie", Cookie)
	http.DefaulHeader.Set("Content-Length", string(bodyStr.Length().ToString()))
	mutex.Unlock()
	// dna.Log(http.DefaulHeader)
	return http.Post(url, bodyStr)
}
Exemple #2
0
// getVideoPlays returns video plays
func getVideoPlays(video *Video, body dna.String) {
	link := "http://www.nhaccuatui.com/interaction/api/hit-counter?jsoncallback=nct"
	http.DefaulHeader.Set("Content-Type", "application/x-www-form-urlencoded ")
	result, err := http.Post(dna.String(link), body)
	// Log(link)
	if err == nil {
		data := &result.Data
		tpl := dna.String(`{"counter":([0-9]+)}`)
		playsArr := data.FindAllStringSubmatch(tpl, -1)
		if len(playsArr) > 0 {
			video.Plays = playsArr[0][1].ToInt()
		}
	}
}
Exemple #3
0
func Post(url dna.String, header dhttp.Header, bodyStr dna.String) (*http.Result, error) {
	http.DefaulHeader = header
	return http.Post(url, bodyStr)
}