Ejemplo n.º 1
0
func pareseScheduleTR(schedule_tr goquery.Nodes) (schedule_int_info map[string]int, schedule_string_info map[string]string) {
	schedule_int_info = make(map[string]int)
	schedule_string_info = make(map[string]string)
	schedule_fenxi_id, _ := strconv.Atoi(schedule_tr.Attr("fid"))
	schedule_int_info["schedule_fenxi_id"] = int(schedule_fenxi_id)
	schedule_string_info["schedule_home"] = common.ConvToGB(schedule_tr.Attr("homesxname"))
	schedule_string_info["schedule_guest"] = common.ConvToGB(schedule_tr.Attr("awaysxname"))
	schedule_string_info["schedule_date"] = schedule_tr.Attr("pdate")
	schedule_string_info["schedule_league"] = common.ConvToGB(schedule_tr.Attr("lg"))
	schedule_string_info["schedule_week_day"] = common.ConvToGB(schedule_tr.Attr("gdate"))
	schedule_string_info["schedule_no"] = schedule_tr.Attr("pname")
	schedule_string_info["schedule_rq_num"] = schedule_tr.Attr("rq")
	week_date := schedule_string_info["schedule_no"][0:1]
	schedule_string_info["schedule_result_no"] = myinit.WeekDesc[week_date] + schedule_string_info["schedule_no"][1:]
	schedule_string_info["schedule_bet_end_time"] = schedule_tr.Attr("pendtime")
	return schedule_int_info, schedule_string_info
}
Ejemplo n.º 2
0
Archivo: pan.go Proyecto: ryancsq/test
func doParsePanUrl(schedule_pan_url string, schedule_fenxi_id int, schedule_string_info map[string]string, date string) (res bool) {
	pan_int_info := make(map[string]int)
	pan_float_info := make(map[string]float32)
	pan_string_info := make(map[string]string)

	pan_html_obj, _ := goquery.ParseUrl(schedule_pan_url)

	schedule_item := pan_html_obj.Find(".odds_hd_cont table tbody tr td")
	home_td := schedule_item.Eq(0)
	guest_td := schedule_item.Eq(4)
	center_td := schedule_item.Eq(2)

	pan_int_info["schedule_fenxi_id"] = schedule_fenxi_id
	pan_string_info["schedule_date"] = schedule_string_info["schedule_date"]
	pan_string_info["schedule_no"] = schedule_string_info["schedule_no"]
	pan_string_info["schedule_result_no"] = schedule_string_info["schedule_result_no"]
	pan_string_info["schedule_league"] = schedule_string_info["schedule_league"]

	pan_string_info["schedule_home"] = common.ConvToGB(home_td.Find("ul li a").Text())
	pan_string_info["schedule_guest"] = common.ConvToGB(guest_td.Find("ul li a").Text())
	pan_string_info["schedule_game_desc"] = common.ConvToGB(center_td.Find(".odds_hd_center .odds_hd_ls a").Text())
	pan_string_info["schedule_date_desc"] = common.ConvToGB(center_td.Find(".odds_hd_center .game_time ").Text())

	odds_tr := pan_html_obj.Find(".table_cont table tbody tr")
	for i := 0; i < odds_tr.Length(); i++ {
		tr_item := odds_tr.Eq(i)
		td_of_company := tr_item.Find("td").Eq(1)
		if td_of_company.Find("p a").Attr("title") == "" {
			continue
		}

		parse_res := doParsePanTr(tr_item, schedule_fenxi_id, pan_int_info, pan_float_info, pan_string_info, false)
		if parse_res == false {
			return false
		}
	}
	if odds_tr.Length() >= 30 {
		ajax_res := ParsePanUrlFromAjax(30, schedule_fenxi_id, pan_string_info)
		if ajax_res == false {
			return false
		}
	}

	return true
}
Ejemplo n.º 3
0
Archivo: pan.go Proyecto: ryancsq/test
func checkPanTr(tr_item goquery.Nodes, schedule_fenxi_id int) (is_useable bool) {
	pan_float_info := make(map[string]float32)
	table_of_pan_detail := tr_item.Find("td .pl_table_data")

	table_of_opentime_pan := table_of_pan_detail.Eq(1)
	tds_of_opentime_pan_table := table_of_opentime_pan.Find("tbody tr td")
	open_pan_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(1).Attr("ref"), 32)
	pan_float_info["open_pan"] = float32(open_pan_32)

	open_home_water_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(0).Text(), 32)
	open_guest_water_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(2).Text(), 32)
	pan_float_info["open_home_water"] = float32(open_home_water_32)
	pan_float_info["open_guest_water"] = float32(open_guest_water_32)

	table_of_realtime_pan := table_of_pan_detail.Eq(0)
	tds_of_realtime_pan_table := table_of_realtime_pan.Find("tbody tr td")

	real_pan_32, _ := strconv.ParseFloat(tds_of_realtime_pan_table.Eq(1).Attr("ref"), 32)
	pan_float_info["real_pan"] = float32(real_pan_32)

	home_real_water_string := common.ConvToGB(tds_of_realtime_pan_table.Eq(0).Text())
	home_real_water_str := strings.Replace(home_real_water_string, "↑", "", -1)
	home_real_water_str = strings.Replace(home_real_water_str, "↓", "", -1)

	guest_real_water_string := common.ConvToGB(tds_of_realtime_pan_table.Eq(2).Text())
	guest_real_water_str := strings.Replace(guest_real_water_string, "↑", "", -1)
	guest_real_water_str = strings.Replace(guest_real_water_str, "↓", "", -1)

	home_real_water_32, _ := strconv.ParseFloat(home_real_water_str, 32)
	guest_real_water_32, _ := strconv.ParseFloat(guest_real_water_str, 32)

	pan_float_info["real_home_water"] = float32(home_real_water_32)
	pan_float_info["real_guest_water"] = float32(guest_real_water_32)
	fmt.Println("check tr:", schedule_fenxi_id, pan_float_info["open_pan"], pan_float_info["real_pan"])
	if pan_float_info["open_pan"] > 0 || pan_float_info["real_pan"] > 0 {
		asiapan.ClearShouPanByScheduleFenxiId(schedule_fenxi_id)
		asiapanbackup.ClearShouPanByScheduleFenxiId(schedule_fenxi_id)
		schedule.ClearScheduleByFenxiId(schedule_fenxi_id)
		fmt.Println("pan html:", pan_float_info["open_pan"], pan_float_info["real_pan"])
		fmt.Println("开盘>0 或者即时盘 >0")
		return false
	}
	return true
}
Ejemplo n.º 4
0
func ParseResultUrl(date string, history bool) {
	if date == "" {
		now := time.Now()
		date = now.Format("2006-01-02")
	}
	result_url := strings.Replace(myinit.ResultUrl, "DDD", date, -1)
	fmt.Println(result_url)
	schedule_string_info := make(map[string]string)
	schedule_float_info := make(map[string]float32)

	pan_string_info := make(map[string]string)
	pan_float_info := make(map[string]float32)
	html_obj, _ := goquery.ParseUrl(result_url)
	schedule_trs := html_obj.Find(".ld_table tbody tr")
	for i, _ := range schedule_trs {
		if i == 0 {
			continue
		}
		tr := schedule_trs.Eq(i)
		tds := tr.Find("td")
		schedule_string_info["schedule_result_no"] = common.ConvToGB(tds.Eq(0).Html())

		schedule_string_info["schedule_score"] = common.ConvToGB(tds.Eq(6).Html())
		schedule_string_info["schedule_spf_result"] = common.ConvToGB(tds.Eq(11).Html())
		schedule_float_info["schedule_spf_odd"] = common.ConvToFloat32(tds.Eq(12).Text())
		schedule_string_info["schedule_rqspf_result"] = common.ConvToGB(tds.Eq(8).Html())
		schedule_float_info["schedule_rqspf_odd"] = common.ConvToFloat32(tds.Eq(9).Text())
		schedule_string_info["schedule_zjq_result"] = common.ConvToGB(tds.Eq(14).Html())
		schedule_float_info["schedule_zjq_odd"] = common.ConvToFloat32(tds.Eq(15).Text())
		schedule_string_info["schedule_bqc_result"] = common.ConvToGB(tds.Eq(17).Html())
		schedule_float_info["schedule_bqc_odd"] = common.ConvToFloat32(tds.Eq(18).Text())

		pan_string_info["schedule_result_no"] = schedule_string_info["schedule_result_no"]
		pan_string_info["schedule_score"] = schedule_string_info["schedule_score"]
		pan_string_info["schedule_spf_result"] = schedule_string_info["schedule_spf_result"]
		pan_string_info["schedule_rqspf_result"] = schedule_string_info["schedule_rqspf_result"]
		pan_string_info["schedule_zjq_result"] = schedule_string_info["schedule_zjq_result"]
		pan_string_info["schedule_bqc_result"] = schedule_string_info["schedule_bqc_result"]
		has := schedule.CheckExistsByResultNoAndDate(schedule_string_info["schedule_result_no"], date)
		if has == false {
			continue
		}
		schedule.UpdateScheduleResult(date, schedule_float_info, schedule_string_info)
		asiapan.UpdateAsiaPanResult(date, schedule_float_info, pan_string_info)
		asiapanlog.UpdateAsiaPanResult(date, pan_float_info, pan_string_info)

	}
}
Ejemplo n.º 5
0
Archivo: pan.go Proyecto: ryancsq/test
func doParsePanTr(date string) (parse_res bool) {
	sql = "select * from pk_asia_pan_backup where schedule_date = ?"

	predict_sql = "chedule_date = ? and schedule_no=? group by predict2_result"

	predict_res_map, _ := myinit.Engine.Query(predict_sql, date)

	td_of_company := tr_item.Find("td").Eq(1)
	company_id := tr_item.Attr("id")
	pan_string_info["company_id"] = company_id
	pan_string_info["company_name"] = common.ConvToGB(td_of_company.Find("p a").Attr("title"))

	var is_big_company = 0
	if td_of_company.Find("p img").Attr("src") == "" {
		is_big_company = 0
	} else {
		is_big_company = 1
		//			fmt.Println("src:" + td_of_company.Find("p img").Attr("src"))
	}
	pan_int_info["is_big_company"] = is_big_company

	table_of_pan_detail := tr_item.Find("td .pl_table_data")

	table_of_opentime_pan := table_of_pan_detail.Eq(1)
	tds_of_opentime_pan_table := table_of_opentime_pan.Find("tbody tr td")
	open_pan_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(1).Attr("ref"), 32)
	pan_float_info["open_pan"] = float32(open_pan_32)
	pan_string_info["open_pan_desc"] = common.ConvToGB(tds_of_opentime_pan_table.Eq(1).Text())

	open_home_water_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(0).Text(), 32)
	open_guest_water_32, _ := strconv.ParseFloat(tds_of_opentime_pan_table.Eq(2).Text(), 32)
	pan_float_info["open_home_water"] = float32(open_home_water_32)
	pan_float_info["open_guest_water"] = float32(open_guest_water_32)

	td_of_pan_time := tr_item.Find("td time")

	pan_string_info["open_pan_time"] = td_of_pan_time.Eq(1).Text()

	table_of_realtime_pan := table_of_pan_detail.Eq(0)
	tds_of_realtime_pan_table := table_of_realtime_pan.Find("tbody tr td")

	real_pan_32, _ := strconv.ParseFloat(tds_of_realtime_pan_table.Eq(1).Attr("ref"), 32)
	pan_float_info["real_pan"] = float32(real_pan_32)
	pan_string_info["real_pan_desc"] = common.ConvToGB(tds_of_realtime_pan_table.Eq(1).Text())

	home_real_water_string := common.ConvToGB(tds_of_realtime_pan_table.Eq(0).Text())
	home_real_water_str := strings.Replace(home_real_water_string, "↑", "", -1)
	home_real_water_str = strings.Replace(home_real_water_str, "↓", "", -1)

	guest_real_water_string := common.ConvToGB(tds_of_realtime_pan_table.Eq(2).Text())
	guest_real_water_str := strings.Replace(guest_real_water_string, "↑", "", -1)
	guest_real_water_str = strings.Replace(guest_real_water_str, "↓", "", -1)

	home_real_water_32, _ := strconv.ParseFloat(home_real_water_str, 32)
	guest_real_water_32, _ := strconv.ParseFloat(guest_real_water_str, 32)

	pan_float_info["real_home_water"] = float32(home_real_water_32)
	pan_float_info["real_guest_water"] = float32(guest_real_water_32)

	pan_string_info["pan_change_time"] = strings.TrimSpace(td_of_pan_time.Eq(0).Text())

	td_item_of_real_pan := tds_of_realtime_pan_table.Eq(1)

	home_pan_change_type := common.ConvToGB(td_item_of_real_pan.Find("font").Text())
	if is_ajax == true {
		home_pan_change_type = td_item_of_real_pan.Find("font").Text()
	}
	fmt.Println("home_pan_desc company:", company_id, pan_string_info["company_name"])

	fmt.Println("home_pan_desc font:", td_item_of_real_pan.Find("font").Text(), common.ConvToGB(td_item_of_real_pan.Find("font").Text()))
	fmt.Println("home_pan_desc before trim:", home_pan_change_type)
	home_pan_change_type = strings.TrimSpace(home_pan_change_type)
	fmt.Println("home_pan_desc:", home_pan_change_type)

	pan_int_info["home_pan_change_type"] = 0
	pan_string_info["home_pan_change_type_desc"] = ""
	if home_pan_change_type == "升" {
		pan_int_info["home_pan_change_type"] = 1
		pan_string_info["home_pan_change_type_desc"] = home_pan_change_type
	}
	if home_pan_change_type == "降" {
		pan_int_info["home_pan_change_type"] = -1
		pan_string_info["home_pan_change_type_desc"] = home_pan_change_type
	}
	fmt.Println("home_pan_change_type_desc:", pan_string_info["home_pan_change_type_desc"])

	home_water_up_down_flag := tds_of_realtime_pan_table.Eq(0).Attr("class")
	pan_int_info["home_water_change_type"] = 0
	pan_string_info["home_water_change_type_desc"] = ""

	if home_water_up_down_flag == "ping" {
		pan_int_info["home_water_change_type"] = -1            // down
		pan_string_info["home_water_change_type_desc"] = "水位降" // down
	}
	if home_water_up_down_flag == "ying" {
		pan_int_info["home_water_change_type"] = 1             // up
		pan_string_info["home_water_change_type_desc"] = "水位升" // up
	}

	//		real_pan_string := strings.Replace(pan_string_info["real_pan_desc"], pan_string_info["home_pan_change_type_desc"], "", -1)
	//		real_pan_desc := strings.TrimSpace(real_pan_string)
	//		fmt.Println("date:", pan_string_info["schedule_date"], pan_string_info["schedule_home"])
	//		fmt.Println("open:", pan_string_info["open_pan_desc"], pan_float_info["open_pan"])
	//		fmt.Println("real:", real_pan_desc, pan_float_info["real_pan"])

	exist_asiapanlog := new(myinit.AsiaPanLog)
	has, f_err := myinit.Engine.Where("schedule_fenxi_id=? AND company_id=? AND pan_change_time=?", schedule_fenxi_id, company_id, pan_string_info["pan_change_time"]).Get(exist_asiapanlog)
	fmt.Println("has:", has, ":", schedule_fenxi_id, ":", company_id, ":", pan_string_info["pan_change_time"])
	fmt.Println("ajax:", f_err)

	if has == true {
		fmt.Println("go has:is:", pan_string_info["pan_change_time"])
		return false
	}

	if pan_float_info["open_pan"] > 0 || pan_float_info["real_pan"] > 0 {
		asiapan.ClearShouPanByScheduleFenxiId(schedule_fenxi_id)
		asiapanbackup.ClearShouPanByScheduleFenxiId(schedule_fenxi_id)

		schedule.ClearScheduleByFenxiId(schedule_fenxi_id)
		//			fmt.Println("pan html:", pan_float_info["open_pan"], pan_float_info["real_pan"])
		fmt.Println("开盘>0 或者即时盘 >0")
		return false
	}

	predict1_result, predict1_cmt := analyse.AnalysePanResult1(pan_int_info, pan_float_info, pan_string_info)
	pan_string_info["predict1_result"] = predict1_result
	pan_string_info["predict1_cmt"] = predict1_cmt
	predict2_result, predict2_cmt := analyse.AnalysePanResult2(pan_int_info, pan_float_info, pan_string_info)
	pan_string_info["predict2_result"] = predict2_result
	pan_string_info["predict2_cmt"] = predict2_cmt

	// fmt.Println("company:" + company)
	// fmt.Println("home_pan_change_type:" + home_pan_change_type)
	// fmt.Println("is big company:" + is_big_company)
	// fmt.Println("change_time:" + change_time)
	// fmt.Println("open_time:" + open_time)
	// fmt.Println("flag:" + home_water_change_type + " " + home_water_up_down_flag)
	//		fmt.Println("home_real_water:", pan_float_info["real_home_water"])
	//		fmt.Println(home_real_water_32)
	//		fmt.Println(float32(home_real_water_32))
	//		fmt.Println("home_real_water water sting:" + home_real_water_str + home_real_water_string)
	//		fmt.Println("guest_real_water:", pan_float_info["real_guest_water"])
	//		fmt.Println("guest_real_water water sting:" + guest_real_water_str + guest_real_water_string)
	//		fmt.Println("pan:", pan_float_info["real_pan"], " ", real_pan_desc)

	// fmt.Println("open_home_water water:", open_home_water)
	// fmt.Println("open_guest_water water:", open_guest_water)
	// fmt.Println("open pan:", open_pan, " ", open_pan_desc)

	addAsiaPan(schedule_fenxi_id, company_id, pan_int_info, pan_float_info, pan_string_info)
	//delete water > 2 and < 1.75
	checkWaterSum(schedule_fenxi_id, company_id, pan_float_info)
	return true
}