|
|
@@ -1,644 +0,0 @@
|
|
|
-# # #!/usr/bin/env python
|
|
|
-# # # -*- coding: utf-8 -*-
|
|
|
-# # __author__ = 'ethereal'
|
|
|
-# # __mtime__ = '2019/3/29'
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # # -*- coding: utf-8 -*-
|
|
|
-# #
|
|
|
-# # # Define your item pipelines here
|
|
|
-# # #
|
|
|
-# # # Don't forget to add your pipeline to the ITEM_PIPELINES setting
|
|
|
-# # # See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
|
|
|
-# #
|
|
|
-# # import time
|
|
|
-# # from .models import st_zq_odds_record, st_zq_odds, database, st_zq_competition, st_zq_league, st_area
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # def inset_odd(match_id,value,utime,ctime,condition,p_id,wanfa):
|
|
|
-# # if st_zq_odds.filter(match_id=match_id):
|
|
|
-# # for k, v in value.items():
|
|
|
-# # st_zq_odd = st_zq_odds.filter(match_id=match_id, odds_code=k,p_code=wanfa)
|
|
|
-# # if st_zq_odd:
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds.update(utime=utime, odds=v).where(st_zq_odds.match_id == match_id,
|
|
|
-# # st_zq_odds.odds_code == k).execute()
|
|
|
-# # else:
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds.create(match_id=match_id, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=condition[k], odds=v, p_id=p_id, p_code=wanfa,odds_code=k)
|
|
|
-# # else:
|
|
|
-# # for k, v in value.items():
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds.create(match_id=match_id, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=condition[k], odds=v, p_id=p_id, p_code=wanfa,
|
|
|
-# # odds_code=k)
|
|
|
-# # for k, v in value.items():
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds_record.create(match_id=match_id, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=condition[k], odds=v, p_id=p_id, p_code=wanfa,
|
|
|
-# # odds_code=k)
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # class Chuanpipeline(object):
|
|
|
-# # def process_item(self, item, spider):
|
|
|
-# # if spider.name == "today_all":
|
|
|
-# # # 让球大小盘
|
|
|
-# # concede_sizes = item.get('concede_size', "")
|
|
|
-# # if concede_sizes:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in concede_sizes.items():
|
|
|
-# # # 比赛日期
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # # 比赛时间
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # # 比赛时间,时间戳
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # # 现在时间,时间戳
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # # 比赛id
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # # 联赛id
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # # 联赛name
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # # 主队
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # # 客队
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # # 主队得分
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # # 客队得分
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # # 全场让球
|
|
|
-# # # number
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # concede_home = value.get('concede_home', "")
|
|
|
-# # concede_home_rule = value.get('concede_home_rule', "")
|
|
|
-# # concede_guest = value.get("concede_guest", "")
|
|
|
-# # concede_guest_rule = value.get("concede_guest_rule", "")
|
|
|
-# # # 上半场让球
|
|
|
-# # half_concede_home = value.get("half_concede_home", "")
|
|
|
-# # half_concede_home_rule = value.get("half_concede_home_rule", "")
|
|
|
-# # half_concede_guest = value.get("half_concede_guest", "")
|
|
|
-# # half_concede_guest_rule = value.get("half_concede_guest_rule", "")
|
|
|
-# # # 全场大小
|
|
|
-# # size_home = value.get('size_home')
|
|
|
-# # size_home_rule = value.get('size_home')
|
|
|
-# # size_guest = value.get('size_guest')
|
|
|
-# # size_guest_rule = value.get('size_guest_rule', "")
|
|
|
-# # # 上半场大小
|
|
|
-# # half_size_home = value.get('half_size_home', "")
|
|
|
-# # half_size_home_rule = value.get('half_size_home_rule', "")
|
|
|
-# # half_size_guest = value.get('half_size_guset', "")
|
|
|
-# # half_size_guest_rule = value.get('half_size_guest_rule', "")
|
|
|
-# # if st_zq_odds.filter(match_id=key):
|
|
|
-# # for k, v in value.items():
|
|
|
-# # if v:
|
|
|
-# # for index, result in enumerate(v):
|
|
|
-# # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code=k,p_code="concede_size")
|
|
|
-# # if st_zq_odd:
|
|
|
-# # if result:
|
|
|
-# # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,st_zq_odds.sort == index,st_zq_odds.odds_code == k).execute()
|
|
|
-# # else:
|
|
|
-# # if result:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,condition=concede_home_rule[index], odds=result, p_id=1,p_code="concede_size", sort=index, odds_code=k)
|
|
|
-# # else:
|
|
|
-# # for k, v in value.items():
|
|
|
-# # if v:
|
|
|
-# # for index, result in enumerate(v):
|
|
|
-# # if result:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=utime, utime=utime, max=result,condition=index, odds=result, p_id=1,p_code="concede_size", sort=index, odds_code=k)
|
|
|
-# # # # 全场让球
|
|
|
-# # # if concede_home:
|
|
|
-# # # for index, result in enumerate(concede_home):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="concede_home")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "concede_home").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="concede_home")
|
|
|
-# # # if concede_guest:
|
|
|
-# # # for index, result in enumerate(concede_guest):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="concede_guest")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "concede_guest").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=concede_guest_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="concede_guest")
|
|
|
-# # # if half_concede_home:
|
|
|
-# # # for index, result in enumerate(half_concede_home):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="half_concede_home")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "half_concede_home").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_concede_home")
|
|
|
-# # # if half_concede_guest:
|
|
|
-# # # for index, result in enumerate(half_concede_guest):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="half_concede_home")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "half_concede_guest").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime,
|
|
|
-# # # max=half_concede_guest[index],
|
|
|
-# # # condition=half_concede_guest_rule[index],
|
|
|
-# # # odds=half_concede_guest[index], p_id=1, p_code="concede_size",
|
|
|
-# # # sort=index, odds_code="half_concede_guest")
|
|
|
-# # # if size_home:
|
|
|
-# # # for index, result in enumerate(size_home):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="size_home")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "size_home").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_home")
|
|
|
-# # # if size_guest:
|
|
|
-# # # for index, result in enumerate(size_home):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="size_guest")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "size_guest").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=size_guest_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_guest")
|
|
|
-# # # if half_size_home:
|
|
|
-# # # for index, result in enumerate(half_size_home):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="half_size_home")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "half_size_home").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_size_home")
|
|
|
-# # # if half_size_guest:
|
|
|
-# # # for index, result in enumerate(half_size_guest):
|
|
|
-# # # st_zq_odd = st_zq_odds.filter(match_id=key, sort=index, odds_code="half_size_guest")
|
|
|
-# # # if st_zq_odd:
|
|
|
-# # # st_zq_odds.update(utime=utime, odds=result).where(st_zq_odds.match_id == key,
|
|
|
-# # # st_zq_odds.sort == index,
|
|
|
-# # # st_zq_odds.odds_code == "half_size_guest").execute()
|
|
|
-# # # else:
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_size_guest_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_size_guest")
|
|
|
-# # # else:
|
|
|
-# # # if concede_home:
|
|
|
-# # # for index, result in enumerate(concede_home):
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="concede_home")
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=concede_guest[index],
|
|
|
-# # # condition=concede_guest_rule[index], odds=concede_guest[index],
|
|
|
-# # # p_id=1, p_code="concede_size", sort=index, odds_code="concede_guest")
|
|
|
-# # # if half_concede_home:
|
|
|
-# # # for index, result in enumerate(half_concede_home):
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_concede_home")
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=half_concede_guest[index],
|
|
|
-# # # condition=half_concede_guest_rule[index],
|
|
|
-# # # odds=half_concede_guest[index], p_id=1, p_code="concede_size",
|
|
|
-# # # sort=index, odds_code="half_concede_guest")
|
|
|
-# # # if size_home:
|
|
|
-# # # for index, result in enumerate(size_home):
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_home")
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=size_guest[index],
|
|
|
-# # # condition=size_guest_rule[index], odds=size_guest[index], p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_guest")
|
|
|
-# # # if half_size_home:
|
|
|
-# # # for index, result in enumerate(half_size_home):
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_size_home")
|
|
|
-# # # if half_size_guest:
|
|
|
-# # # for index, result in enumerate(half_size_guest):
|
|
|
-# # # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=half_size_guest[index],
|
|
|
-# # # condition=half_size_guest_rule[index], odds=half_size_guest[index],
|
|
|
-# # # p_id=1, p_code="concede_size", sort=index,
|
|
|
-# # # odds_code="half_size_guest")
|
|
|
-# # # if concede_home:
|
|
|
-# # # for index, result in enumerate(concede_home):
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="concede_home")
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=concede_guest[index],
|
|
|
-# # # condition=concede_guest_rule[index], odds=concede_guest[index],
|
|
|
-# # # p_id=1, p_code="concede_size", sort=index,
|
|
|
-# # # odds_code="concede_guest")
|
|
|
-# # # if half_concede_home:
|
|
|
-# # # for index, result in enumerate(half_concede_home):
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_concede_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_concede_home")
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime,
|
|
|
-# # # max=half_concede_guest[index],
|
|
|
-# # # condition=half_concede_guest_rule[index],
|
|
|
-# # # odds=half_concede_guest[index], p_id=1, p_code="concede_size",
|
|
|
-# # # sort=index, odds_code="half_concede_guest")
|
|
|
-# # # if size_home:
|
|
|
-# # # for index, result in enumerate(size_home):
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_home")
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=size_guest[index],
|
|
|
-# # # condition=size_guest_rule[index], odds=size_guest[index], p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="size_guest")
|
|
|
-# # # if half_size_home:
|
|
|
-# # # for index, result in enumerate(half_size_home):
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=result,
|
|
|
-# # # condition=half_size_home_rule[index], odds=result, p_id=1,
|
|
|
-# # # p_code="concede_size", sort=index, odds_code="half_size_home")
|
|
|
-# # # if half_size_guest:
|
|
|
-# # # for index, result in enumerate(half_size_guest):
|
|
|
-# # # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=half_size_guest[index],
|
|
|
-# # # condition=half_size_guest_rule[index], odds=half_size_guest[index],
|
|
|
-# # # p_id=1, p_code="concede_size", sort=index,
|
|
|
-# # # odds_code="half_size_guest")
|
|
|
-# # # if st_zq_competition.filter(match_id=key):
|
|
|
-# # # pass
|
|
|
-# # # else:
|
|
|
-# # # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# # # 独赢
|
|
|
-# # capots = item.get('capot', "")
|
|
|
-# # if capots:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in capots.items():
|
|
|
-# # # 比赛日期
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # # 比赛时间
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # # 比赛id
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # # 联赛id
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # # 联赛name
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # # 主队
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # # 客队
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # # 主队得分
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # # 客队得分
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # # number
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # capot_dict = {"capot_home":"1","capot_guest": "2","capot_dogfall":"x","half_capot_home":"1","half_capot_guest": "2","half_capot_dogfall":"x"}
|
|
|
-# # if corner_ball:
|
|
|
-# # wanfa = corner_ball
|
|
|
-# # p_id = 9
|
|
|
-# # else:
|
|
|
-# # wanfa = "capot"
|
|
|
-# # p_id = 2
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=capot_dict, p_id=p_id, wanfa=wanfa)
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # # 入球数-单双
|
|
|
-# # odd_evens = item.get("odd_even", "")
|
|
|
-# # if odd_evens:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in odd_evens.items():
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # odd_even_dict = {"odd_even_odd":"单","odd_even_even": "双","half_odd_even_odd": "单","half_odd_even_even":"双"}
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=odd_even_dict, p_id=3, wanfa="odd_even")
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# # # 总入球
|
|
|
-# # total_goals = item.get('total_goal', "")
|
|
|
-# # if total_goals:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in total_goals.items():
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # total_dict = {'total_goal_zero': '0-1', 'total_goal_two': '2-3', 'total_goal_four': '4-6',
|
|
|
-# # 'total_goal_seven': '7或以上', 'half_total_goal_zero': '0', "half_total_goal_one": '1',
|
|
|
-# # "half_total_goal_two": '2', "half_total_goal_three": '3或以上'}
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=total_dict, p_id=4, wanfa="total_goal")
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# # # 半场/全场
|
|
|
-# # half_fulls = item.get("half_full", "")
|
|
|
-# # if half_fulls:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in half_fulls.items():
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # full_dict = {"half_full_home_home": "主主", "half_full_home_dogfall": "主和",
|
|
|
-# # "half_full_home_guest": "主客", "half_full_dogfall_home": "和主",
|
|
|
-# # "half_full_dogfall_dogfall": "和和", "half_full_dogfall_guest": "和客",
|
|
|
-# # "half_full_guest_home": "客主", "half_full_guest_dogfall": "客和",
|
|
|
-# # "half_full_guest_guest": "客客"}
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=full_dict, p_id=5,wanfa="half_full")
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # # 波胆
|
|
|
-# # bodans = item.get("bodan", "")
|
|
|
-# # if bodans:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in bodans.items():
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # new_bodan = value['bodan']
|
|
|
-# # bodan_dict = {"bodan_home_one_zero": "1-0", "bodan_home_two_zero": "2-0",
|
|
|
-# # "bodan_home_two_one": "2-1", "bodan_home_three_zero": "3-0",
|
|
|
-# # "bodan_home_three_one": "3-1", "bodan_home_three_two": "3-2",
|
|
|
-# # "bodan_home_four_zero": "4-0", "bodan_home_four_one": "4-1",
|
|
|
-# # "bodan_home_four_two": "4-2", "bodan_home_four_three": "4-3",
|
|
|
-# # "bodan_guest_one_zero": "1-0", "bodan_guest_two_zero": "2-0",
|
|
|
-# # "bodan_guest_two_one": "2-0", "bodan_guest_three_zero": "3-0",
|
|
|
-# # "bodan_guest_three_one": "3-1", "bodan_guest_three_two": "3-2",
|
|
|
-# # "bodan_guest_four_zero": "4-0", "bodan_guest_four_one": "4-1",
|
|
|
-# # "bodan_guest_four_two": "4-2", "bodan_guest_four_three": "4-3",
|
|
|
-# # "bodan_dogfall_zero_zero": "0-0", "bodan_dogfall_one_one": "1-1",
|
|
|
-# # "bodan_dogfall_two_two": "2-2", "bodan_dogfall_three_three": "3-3",
|
|
|
-# # "bodan_dogfall_four_four": "4-4", "bodan_other": "其他"}
|
|
|
-# # # 插入全场波胆
|
|
|
-# # if new_bodan:
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=bodan_dict, p_id=6,
|
|
|
-# # wanfa="bodan")
|
|
|
-# #
|
|
|
-# # half_bodan = value['half_bodan']
|
|
|
-# # half_bodan_dict = {"bodan_home_one_zero": "1-0", "bodan_home_two_zero": "2-0",
|
|
|
-# # "bodan_home_two_one": "2-1", "bodan_home_three_zero": "3-0",
|
|
|
-# # "bodan_home_three_one": "3-1", "bodan_home_three_two": "3-2",
|
|
|
-# # "bodan_guest_one_zero": "1-0", "bodan_guest_two_zero": "2-0",
|
|
|
-# # "bodan_guest_two_one": "2-0", "bodan_guest_three_zero": "3-0",
|
|
|
-# # "bodan_guest_three_one": "3-1", "bodan_guest_three_two": "3-2",
|
|
|
-# # "bodan_dogfall_zero_zero": "0-0", "bodan_dogfall_one_one": "1-1",
|
|
|
-# # "bodan_dogfall_two_two": "2-2", "bodan_dogfall_three_three": "3-3",
|
|
|
-# # "bodan_other": "其他"}
|
|
|
-# # if half_bodan:
|
|
|
-# # if st_zq_odds.filter(match_id=key):
|
|
|
-# # for k, v in half_bodan.items():
|
|
|
-# # st_zq_odd = st_zq_odds.filter(match_id=key, odds_code="half_"+k,p_code="bodan")
|
|
|
-# # if st_zq_odd:
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds.update(utime=utime, odds=v).where(st_zq_odds.match_id == key,
|
|
|
-# # st_zq_odds.odds_code == k).execute()
|
|
|
-# # else:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=half_bodan_dict[k], odds=v, p_id=6, p_code="bodan",
|
|
|
-# # odds_code="half_"+k)
|
|
|
-# # else:
|
|
|
-# # for k, v in half_bodan.items():
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=half_bodan_dict[k], odds=v, p_id=6, p_code="bodan",
|
|
|
-# # odds_code="half_"+k)
|
|
|
-# # for k, v in half_bodan.items():
|
|
|
-# # if v:
|
|
|
-# # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=v,
|
|
|
-# # condition=half_bodan_dict[k], odds=v, p_id=6, p_code="bodan",odds_code="half_"+k)
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home,guest_team=team_guest,lg_id=league_id,match_id=competition_id, match_date=r_ctime, match_time=time_game,ctime=utime,utime=utime,tag=number)
|
|
|
-# #
|
|
|
-# # #最先/最后进球
|
|
|
-# # first_last_balls = item.get("first_last_ball","")
|
|
|
-# # if first_last_balls:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in first_last_balls.items():
|
|
|
-# # data_game = value.pop('data_game').split("/")
|
|
|
-# # month = str(data_game[1].strip())
|
|
|
-# # day = str(data_game[0])
|
|
|
-# # time_game = str(value.pop('time_game'))
|
|
|
-# # ctime = "2019" + "-" + month + "-" + day + "" + time_game + ":00"
|
|
|
-# # r_ctime = "2019" + "-" + month + "-" + day
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # competition_id = value.pop('game_id')
|
|
|
-# # league_id = value.pop('league_id')
|
|
|
-# # league_name = value.pop('league_name')
|
|
|
-# # team_home = value.pop('team_home')
|
|
|
-# # team_guest = value.pop('team_guest')
|
|
|
-# # score_home = value.pop('score_home')
|
|
|
-# # score_guest = value.pop('score_guest')
|
|
|
-# # number = value.pop('number')
|
|
|
-# # corner_ball = value.pop('corner_ball')
|
|
|
-# # half_way = value.pop('half_way')
|
|
|
-# # first_last_dict = {"first_last_ball":"最先进球","first_ball_home":"最后进球","first_ball_guest":"最先进球","last_ball_home":"最后进球","last_ball_guest": "最后进球","not_ball":"没有进球"}
|
|
|
-# # inset_odd(match_id=key, value=value, utime=utime, ctime=utime, condition=first_last_dict, p_id=7,wanfa="first_last_ball")
|
|
|
-# #
|
|
|
-# # if st_zq_competition.filter(match_id=key):
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_competition.create(home_team=team_home, guest_team=team_guest, lg_id=league_id,
|
|
|
-# # match_id=competition_id, match_date=r_ctime, match_time=time_game, ctime=utime,
|
|
|
-# # utime=utime, tag=number)
|
|
|
-# #
|
|
|
-# # # 冠军
|
|
|
-# # champions = item.get("champion","")
|
|
|
-# # if champions:
|
|
|
-# # with database.atomic():
|
|
|
-# # for key, value in champions.items():
|
|
|
-# # data_game = value['data_game'].replace('年',"-").replace('月',"-").replace('日',"")
|
|
|
-# # time_game = value['time_game']
|
|
|
-# # ctime = data_game + " " + time_game
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # league_name =value['league_name']
|
|
|
-# # tema_home = value['tema_home']
|
|
|
-# # league_id = value['league_id']
|
|
|
-# # game_id = value['game_id']
|
|
|
-# # new_league_name = value['new_league_name']
|
|
|
-# # champion_team = value['champion_team']
|
|
|
-# # new_champion = value['new_champion']
|
|
|
-# # if st_zq_odds.filter(match_id=key):
|
|
|
-# # st_zq_odd = st_zq_odds.filter(match_id=key, odds_code=tema_home)
|
|
|
-# # if st_zq_odd:
|
|
|
-# # if new_champion:
|
|
|
-# # st_zq_odds.update(utime=utime, odds=champion_team).where(st_zq_odds.match_id == key,
|
|
|
-# # st_zq_odds.odds_code == k).execute()
|
|
|
-# # else:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=champion_team,
|
|
|
-# # condition=new_champion, odds=champion_team, p_id=8, p_code="champion",odds_code=tema_home)
|
|
|
-# # else:
|
|
|
-# # if new_champion:
|
|
|
-# # st_zq_odds.create(match_id=key, ctime=ctime, utime=utime, max=champion_team,condition=new_champion, odds=champion_team, p_id=8, p_code="champion",odds_code=tema_home)
|
|
|
-# # if new_champion:
|
|
|
-# # st_zq_odds_record.create(match_id=key, ctime=ctime, utime=utime, max=champion_team,condition=new_champion, odds=champion_team, p_id=8, p_code="champion",odds_code=tema_home)
|
|
|
-# #
|
|
|
-# #
|
|
|
-# # class Lianpipeline(object):
|
|
|
-# # def process_item(self, item, spider):
|
|
|
-# # # print(item)
|
|
|
-# # # if spider.name == "liansai":
|
|
|
-# # area_id = item["area_id"]
|
|
|
-# # area_name = item["area_name"]
|
|
|
-# # st_league = item["st_zq_league"]
|
|
|
-# # name_chinese = item["name_chinese"]
|
|
|
-# # st_zq_leagues = st_zq_league.filter(id=st_league)
|
|
|
-# # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
-# # if st_zq_leagues:
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_zq_league.create(name_chinese=name_chinese,id=st_league,country_id=area_id,if_stop=0,league_list=0,bf_Ifdisplay=0,if_have_sub=0,curr_round=0)
|
|
|
-# # area_ids = st_area.filter(id=area_id)
|
|
|
-# # if area_ids:
|
|
|
-# # pass
|
|
|
-# # else:
|
|
|
-# # st_area.create(id=area_id, title=area_name, create_time=utime)
|
|
|
-# #
|
|
|
-# import random
|
|
|
-# import time
|
|
|
-# class MySnow:
|
|
|
-# def __init__(self,dataID):
|
|
|
-# self.start = int(time.mktime(time.strptime('2018-01-01 00:00:00', "%Y-%m-%d %H:%M:%S")))
|
|
|
-# self.last = int(time.time())
|
|
|
-# self.countID = 0
|
|
|
-# self.dataID = dataID # 数据ID,这个自定义或是映射
|
|
|
-#
|
|
|
-# def get_id(self):
|
|
|
-# # 时间差部分
|
|
|
-# now = int(time.time())
|
|
|
-# temp = now-self.start
|
|
|
-# if len(str(temp)) < 9: # 时间差不够9位的在前面补0
|
|
|
-# length = len(str(temp))
|
|
|
-# s = "0" * (9-length)
|
|
|
-# temp = s + str(temp)
|
|
|
-# if now == self.last:
|
|
|
-# self.countID += 1 # 同一时间差,序列号自增
|
|
|
-# else:
|
|
|
-# self.countID = 0 # 不同时间差,序列号重新置为0
|
|
|
-# self.last = now
|
|
|
-# # 标识ID部分
|
|
|
-# if len(str(self.dataID)) < 2:
|
|
|
-# length = len(str(self.dataID))
|
|
|
-# s = "0" * (2-length)
|
|
|
-# self.dataID = s + str(self.dataID)
|
|
|
-# # 自增序列号部分
|
|
|
-# if self.countID == 99999: # 序列号自增5位满了,睡眠一秒钟
|
|
|
-# time.sleep(1)
|
|
|
-# countIDdata = str(self.countID)
|
|
|
-# if len(countIDdata) < 5: # 序列号不够5位的在前面补0
|
|
|
-# length = len(countIDdata)
|
|
|
-# s = "0"*(5-length)
|
|
|
-# countIDdata = s + countIDdata
|
|
|
-# id = str(temp) + str(self.dataID) + countIDdata
|
|
|
-# return id
|
|
|
-#
|
|
|
-#
|
|
|
-# snow = MySnow(dataID="097571")
|
|
|
-# print(snow.get_id())
|
|
|
-# a = len(snow.get_id())
|
|
|
-# print(a)
|
|
|
-#
|
|
|
-#
|
|
|
-# def shuffle_list(some_list):
|
|
|
-# randomized_list = some_list[:]
|
|
|
-# while True:
|
|
|
-# random.shuffle(randomized_list)
|
|
|
-# for a, b in zip(some_list, randomized_list):
|
|
|
-# if a == b:
|
|
|
-# break
|
|
|
-# else:
|
|
|
-# return randomized_list
|
|
|
-#
|