示例#1
0
文件: header.go 项目: olragon/dna
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)
}
示例#2
0
文件: video.go 项目: olragon/dna
// 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()
		}
	}
}
示例#3
0
文件: post.go 项目: olragon/dna
func Post(url dna.String, header dhttp.Header, bodyStr dna.String) (*http.Result, error) {
	http.DefaulHeader = header
	return http.Post(url, bodyStr)
}