|
|
@@ -11,7 +11,7 @@ import psycopg2
|
|
|
import psycopg2.extras
|
|
|
from .ball_func import zqone_intodb, get_pcode, zqtwo_intodb, new_time, out_time, zqone_competition, zqtwo_competition, \
|
|
|
zqthree_competition, two_intodb, one_intodb, three_intodb, wqone_intodb, hash_func, r_func, bqone_intodb, gjz_into, \
|
|
|
- gjl_into, gjw_into, gjb_into, new_times, zqone_intodbs, zqtwo_intodbs, zqone_competitions
|
|
|
+ gjl_into, gjw_into, gjb_into, new_times, zqone_intodbs, zqtwo_intodbs, zqone_competitions, fuhao
|
|
|
|
|
|
|
|
|
# 足球 赔率 赛事---------------------------------------------------------------------------------------------------------
|
|
|
@@ -569,16 +569,9 @@ class Lanqiupipeline(object):
|
|
|
|
|
|
# 网球 让球&大小盘--------------------------------------------------------------------------------------------------------
|
|
|
class Wangqiupipeline(object):
|
|
|
- def open_spider(self, spider):
|
|
|
- self.pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"],
|
|
|
- password=settings["R_PASSWORD"])
|
|
|
- self.redis_db = redis.StrictRedis(connection_pool=self.pool)
|
|
|
- self.conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"],
|
|
|
- password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
|
|
|
- self.cursor = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
|
|
-
|
|
|
def process_item(self, item, spider):
|
|
|
logger = logging.getLogger(__name__)
|
|
|
+ url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
# logger.warning(query.addErrback(self.handle_error, item, spider))
|
|
|
# 联赛id
|
|
|
league_id = item['league_id']
|
|
|
@@ -587,6 +580,7 @@ class Wangqiupipeline(object):
|
|
|
# result = item['result']
|
|
|
# 比赛id
|
|
|
game_id = item['game_id']
|
|
|
+ print(game_id)
|
|
|
# 球队1
|
|
|
team_home = item['team_home']
|
|
|
# 球队2
|
|
|
@@ -642,104 +636,171 @@ class Wangqiupipeline(object):
|
|
|
odd_evens_dict_rule = item['odd_evens_dict_rule']
|
|
|
wangqiu = item['wangqiu']
|
|
|
|
|
|
- # 让盘
|
|
|
- concede = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 1, 'p_code': "dishes",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- wqone_intodb(data1=concedes_dict, data2=concede, data3=concedes_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球concedes_dict插入错误')
|
|
|
- logger.warning(e)
|
|
|
- # 让局
|
|
|
- bureaus = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 3, 'p_code': "bureau",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- wqone_intodb(data1=bureaus_dict, data2=bureaus, data3=bureaus_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球bureaus_dict插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- total_number = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 4,
|
|
|
- 'p_code': "total_number", 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- wqone_intodb(data1=total_number_dict, data2=total_number, data3=total_number_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球total_number_dict插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- odd_evens = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 5, 'p_code': "two_game_sides",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- wqone_intodb(data1=odd_evens_dict, data2=odd_evens, data3=odd_evens_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球odd_evens_dict插入错误')
|
|
|
- logger.warning(e)
|
|
|
+ us_time = ctime
|
|
|
match_date, match_time, time3 = new_time(ctime)
|
|
|
n_time = out_time(time3, 3)
|
|
|
+ # try:
|
|
|
+ # if pt is 1:
|
|
|
+ # Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (
|
|
|
+ # team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
+ # n_time,1, us_time, number, n_time, 1))
|
|
|
+ # if pt is 2:
|
|
|
+ # Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (
|
|
|
+ # team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
+ # n_time,1, us_time, number, n_time, 1))
|
|
|
+ # if pt is 3:
|
|
|
+ # Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (
|
|
|
+ # team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
+ # n_time,1, us_time, number, n_time, 1))
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球st_wq_competition插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ # 插入赛事表
|
|
|
+ if wangqiu == "网球":
|
|
|
+ if pt == 1:
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 1,
|
|
|
+ "is_morningplate": 0,
|
|
|
+ "is_stringscene": 0,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
+ if pt == 2:
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 0,
|
|
|
+ "is_morningplate": 1,
|
|
|
+ "is_stringscene": 0,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
+ if pt == 3:
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 0,
|
|
|
+ "is_morningplate": 0,
|
|
|
+ "is_stringscene": 1,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
+
|
|
|
+ # # 让盘
|
|
|
+ # concede = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 1, 'p_code': "dishes",
|
|
|
+ # 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
+ # try:
|
|
|
+ # wqone_intodb(data1=concedes_dict, data2=concede, data3=concedes_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球concedes_dict插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ # # 让局
|
|
|
+ # bureaus = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 3, 'p_code': "bureau",
|
|
|
+ # 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
+ # try:
|
|
|
+ # wqone_intodb(data1=bureaus_dict, data2=bureaus, data3=bureaus_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球bureaus_dict插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ #
|
|
|
+ # total_number = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 4,
|
|
|
+ # 'p_code': "total_number", 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
+ # try:
|
|
|
+ # wqone_intodb(data1=total_number_dict, data2=total_number, data3=total_number_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球total_number_dict插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ #
|
|
|
+ # odd_evens = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 5, 'p_code': "two_game_sides",
|
|
|
+ # 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
+ # try:
|
|
|
+ # wqone_intodb(data1=odd_evens_dict, data2=odd_evens, data3=odd_evens_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球odd_evens_dict插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
if kemps_dict:
|
|
|
for key, value in kemps_dict.items():
|
|
|
if value:
|
|
|
new_hash = hash_func(match_id=game_id, odds_code=key, sort=0, p_id=2)
|
|
|
r_hash = r_func(match_id=game_id, odds_code=key, sort=0, p_id=2, odd=value)
|
|
|
- odds_only = r_hash
|
|
|
- if self.redis_db.hexists("hg3535_wangqiu", r_hash):
|
|
|
- pass
|
|
|
- else:
|
|
|
- self.redis_db.hset("hg3535_wangqiu", r_hash, 0)
|
|
|
- try:
|
|
|
- sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole,odds_only,expire_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime = %s,odds = %s,odds_only=%s;"
|
|
|
- self.cursor.execute(sql1, (
|
|
|
- int(league_id), key, int(game_id), utime, utime, value, 2, "kemp", 0, "hg3535", new_hash,
|
|
|
- odds_only,expire_time, utime, value, odds_only))
|
|
|
- # 更新主队st_zq_odds_record表
|
|
|
- sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s);"
|
|
|
- self.cursor.execute(sql2, (
|
|
|
- int(league_id), key, int(game_id), utime, utime, value, 2, "kemp", 0, "hg3535", odds_only))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球kemps_dict插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- us_time = ctime
|
|
|
- # 插入赛事表
|
|
|
- if wangqiu == "网球":
|
|
|
- try:
|
|
|
- if pt is 1:
|
|
|
- Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time,1, us_time, number, n_time, 1))
|
|
|
- if pt is 2:
|
|
|
- Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time,1, us_time, number, n_time, 1))
|
|
|
- if pt is 3:
|
|
|
- Competition_sql = "insert into st_wq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time,1, us_time, number, n_time, 1))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球st_wq_competition插入错误')
|
|
|
- logger.warning(e)
|
|
|
+ # odds_only = r_hash
|
|
|
+ payload_bodan = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": game_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "bodan",
|
|
|
+ "odds": value,
|
|
|
+ "condition": 0,
|
|
|
+ "odds_only": r_hash,
|
|
|
+ "sole": new_hash,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_bodan)})
|
|
|
+ print(json.dumps(payload_bodan))
|
|
|
+ print(resp.text, '网球独赢/冠军')
|
|
|
return item
|
|
|
|
|
|
- def close_spider(self, spider):
|
|
|
- self.conn.commit()
|
|
|
- self.conn.close()
|
|
|
-
|
|
|
|
|
|
# 网球 波胆--------------------------------------------------------------------------------------------------------------
|
|
|
class Wqbodanpipeline(object):
|
|
|
- def open_spider(self, spider):
|
|
|
- self.pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"],
|
|
|
- password=settings["R_PASSWORD"])
|
|
|
- self.redis_db = redis.StrictRedis(connection_pool=self.pool)
|
|
|
- self.conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"],
|
|
|
- password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
|
|
|
- self.cursor = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
|
|
-
|
|
|
def process_item(self, item, spider):
|
|
|
# 使用twisted将mysql插入变成异步执行
|
|
|
+ url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
logger = logging.getLogger(__name__)
|
|
|
# logger.warning(query.addErrback(self.handle_error, item, spider))
|
|
|
# 比赛日期
|
|
|
@@ -803,42 +864,37 @@ class Wqbodanpipeline(object):
|
|
|
new_hash = hash_func(match_id=competition_id, odds_code=key, sort=0, p_id=7)
|
|
|
r_hash = r_func(match_id=competition_id, odds_code=key, sort=0, p_id=7, odd=value)
|
|
|
odds_only = r_hash
|
|
|
- if self.redis_db.hexists("hg3535_wangqiu", r_hash):
|
|
|
- pass
|
|
|
- else:
|
|
|
- self.redis_db.hset("hg3535_wangqiu", r_hash, 0)
|
|
|
- try:
|
|
|
- sql1 = "insert into st_wq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole, condition, expire_time,odds_only) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime=%s,odds=%s,expire_time=%s,odds_only=%s;"
|
|
|
- self.cursor.execute(sql1, (
|
|
|
- int(league_id), key, int(competition_id), utime, utime, value, p_id, p_code, 0, "hg3535",
|
|
|
- new_hash, bodan_dict[key], expire_time, odds_only,utime, value, expire_time, odds_only))
|
|
|
- # 更新主队st_zq_odds_record表
|
|
|
- sql2 = "insert into st_wq_odds_record(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, condition,odds_only) values (%s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s, %s);"
|
|
|
- self.cursor.execute(sql2, (
|
|
|
- int(league_id), key, int(competition_id), utime, utime, value, p_id, p_code, 0, "hg3535", key,odds_only))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球波胆插入错误')
|
|
|
- logger.warning(e)
|
|
|
+ payload_bodan = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": competition_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "bodan",
|
|
|
+ "odds": value,
|
|
|
+ "condition": bodan_dict[key],
|
|
|
+ "odds_only": odds_only,
|
|
|
+ "sole": new_hash,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_bodan)})
|
|
|
+ print(json.dumps(payload_bodan))
|
|
|
+ print(resp.text, '网球波胆')
|
|
|
return item
|
|
|
|
|
|
- def close_spider(self, spider):
|
|
|
- self.conn.commit()
|
|
|
- self.conn.close()
|
|
|
-
|
|
|
|
|
|
# 棒球 让球&大小盘--------------------------------------------------------------------------------------------------------
|
|
|
class Bangqiupipeline(object):
|
|
|
- def open_spider(self, spider):
|
|
|
- self.pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"],
|
|
|
- password=settings["R_PASSWORD"])
|
|
|
- self.redis_db = redis.StrictRedis(connection_pool=self.pool)
|
|
|
- self.conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"],
|
|
|
- password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
|
|
|
- self.cursor = self.conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
|
|
|
-
|
|
|
def process_item(self, item, spider):
|
|
|
# print(item)
|
|
|
logger = logging.getLogger(__name__)
|
|
|
+ url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
# logger.warning(query.addErrback(self.handle_error, item, spider))
|
|
|
# 联赛id
|
|
|
league_id = item['league_id']
|
|
|
@@ -862,6 +918,7 @@ class Bangqiupipeline(object):
|
|
|
month = str(data_game[1].strip())
|
|
|
day = str(data_game[0])
|
|
|
except Exception as e:
|
|
|
+ logger.warning('data_game字段分割错误')
|
|
|
logger.warning(e)
|
|
|
data_game = item['data_game'].split(" ")
|
|
|
months = str(data_game[1].strip())
|
|
|
@@ -886,7 +943,6 @@ class Bangqiupipeline(object):
|
|
|
# 球队得分
|
|
|
qiudui = item['qiudui']
|
|
|
pt = item['pt']
|
|
|
-
|
|
|
# 让球
|
|
|
concedes_dict = item['concedes_dict']
|
|
|
concedes_dict_rule = item['concedes_dict_rule']
|
|
|
@@ -899,34 +955,172 @@ class Bangqiupipeline(object):
|
|
|
odd_evens_dict = item['odd_evens_dict']
|
|
|
odd_evens_dict_rule = item['odd_evens_dict_rule']
|
|
|
bangqiu = item['bangqiu']
|
|
|
-
|
|
|
+ match_date, match_time, time3 = new_time(ctime)
|
|
|
+ us_time = ctime
|
|
|
+ # 插入赛事表
|
|
|
+ if bangqiu == '棒球':
|
|
|
+ if pt == 1:
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 1,
|
|
|
+ "is_morningplate": 0,
|
|
|
+ "is_stringscene": 0,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
+ if pt == 2:
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 0,
|
|
|
+ "is_morningplate": 1,
|
|
|
+ "is_stringscene": 0,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
+ if pt == 3:
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "competition",
|
|
|
+ "data": {
|
|
|
+ "home_team": team_home,
|
|
|
+ "guest_team": team_guest,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "status": 0,
|
|
|
+ "match_id": game_id,
|
|
|
+ "match_date": match_date,
|
|
|
+ "match_time": match_time,
|
|
|
+ "tag": number,
|
|
|
+ "source": "hg3535",
|
|
|
+ "is_rollball": 0,
|
|
|
+ "is_today": 0,
|
|
|
+ "is_morningplate": 0,
|
|
|
+ "is_stringscene": 1,
|
|
|
+ "us_time": us_time
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(json.dumps(payload))
|
|
|
+ print(resp.text)
|
|
|
# 让球
|
|
|
- concede = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 1, 'p_code': "concede",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- bqone_intodb(data1=concedes_dict, data2=concede, data3=concedes_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球concede插入错误')
|
|
|
- logger.warning(e)
|
|
|
+ if concedes_dict:
|
|
|
+ for key, value in concedes_dict.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=game_id, odds_code=key, sort=0, p_id=1)
|
|
|
+ r_hash = r_func(match_id=game_id, odds_code=key, sort=0, p_id=1, odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ b_f = fuhao(str(concedes_dict_rule[key]))
|
|
|
+ payload_concede = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": game_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "concede",
|
|
|
+ "odds": value,
|
|
|
+ "condition": b_f,
|
|
|
+ "odds_only": new_hash,
|
|
|
+ "sole": odds_only,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_concede)})
|
|
|
+ print(json.dumps(payload_concede))
|
|
|
+ print(resp.text, '棒球让球')
|
|
|
# 总得分:大/小
|
|
|
- total_size = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 2, 'p_code': "total_size",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- bqone_intodb(data1=total_size_dict, data2=total_size, data3=total_size_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球total_size插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- odd_even = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 3, 'p_code': "two_sides",
|
|
|
- 'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
|
|
|
- try:
|
|
|
- bqone_intodb(data1=odd_evens_dict, data2=odd_even, data3=odd_evens_dict_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球odd_even插入错误')
|
|
|
- logger.warning(e)
|
|
|
- # 赛事失效时间
|
|
|
- match_date, match_time, time3 = new_time(ctime)
|
|
|
- n_time = out_time(time3, 3.5)
|
|
|
+ if total_size_dict:
|
|
|
+ for key, value in total_size_dict.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=game_id, odds_code=key, sort=0, p_id=2)
|
|
|
+ r_hash = r_func(match_id=game_id, odds_code=key, sort=0, p_id=2, odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ b_f = fuhao(str(total_size_dict_rule[key]))
|
|
|
+ payload_total_size = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": game_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "total_size",
|
|
|
+ "odds": value,
|
|
|
+ "condition": b_f,
|
|
|
+ "odds_only": new_hash,
|
|
|
+ "sole": odds_only,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_total_size)})
|
|
|
+ print(json.dumps(payload_total_size))
|
|
|
+ print(resp.text, '-----total_size')
|
|
|
+ # 单双
|
|
|
+ if odd_evens_dict:
|
|
|
+ for key, value in odd_evens_dict.items():
|
|
|
+ if value:
|
|
|
+ new_hash = hash_func(match_id=game_id, odds_code=key, sort=0, p_id=3)
|
|
|
+ r_hash = r_func(match_id=game_id, odds_code=key, sort=0, p_id=3, odd=value)
|
|
|
+ odds_only = r_hash
|
|
|
+ b_f = fuhao(str(odd_evens_dict_rule[key]))
|
|
|
+ payload_odd_even = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": game_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "two_sides",
|
|
|
+ "odds": value,
|
|
|
+ "condition": b_f,
|
|
|
+ "odds_only": new_hash,
|
|
|
+ "sole": odds_only,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_odd_even)})
|
|
|
+ print(json.dumps(payload_odd_even))
|
|
|
+ print(resp.text, '-----odd_even')
|
|
|
# 插入独赢
|
|
|
if capots_dict:
|
|
|
for key, value in capots_dict.items():
|
|
|
@@ -934,51 +1128,30 @@ class Bangqiupipeline(object):
|
|
|
new_hash = hash_func(match_id=game_id, odds_code=key, sort=0, p_id=4)
|
|
|
r_hash = r_func(match_id=game_id, odds_code=key, sort=0, p_id=4, odd=value)
|
|
|
odds_only = r_hash
|
|
|
- if self.redis_db.hexists("hg3535_bangqiu", r_hash):
|
|
|
- pass
|
|
|
- else:
|
|
|
- self.redis_db.hset("hg3535_bangqiu", r_hash, 0)
|
|
|
- try:
|
|
|
- sql1 = "insert into st_bq_odds(lg_id, odds_code, match_id, ctime, utime, odds, p_id, p_code, sort, source, sole,odds_only,expire_time) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s, %s,%s) on conflict(sole) do update set utime = %s,odds = %s,odds_only=%s,expire_time=%s;"
|
|
|
- self.cursor.execute(sql1, (
|
|
|
- int(league_id), key, int(game_id), utime, utime, value, 4, "capot", 0, "hg3535", new_hash,
|
|
|
- odds_only, expire_time,utime, value, odds_only, expire_time))
|
|
|
- # 更新主队st_zq_odds_record表
|
|
|
- sql2 = "insert into st_bq_odds_record(lg_id, odds_code, match_id, ctime, utime,odds, p_id, p_code, sort, source,odds_only) values (%s, %s, %s, %s, %s, %s, %s,%s, %s, %s, %s);"
|
|
|
- self.cursor.execute(sql2, (
|
|
|
- int(league_id), key, int(game_id), utime, utime, value, 4, "capot", 0, "hg3535", odds_only))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球独赢插入错误')
|
|
|
- logger.warning(e)
|
|
|
- us_time = ctime
|
|
|
- # 插入赛事表
|
|
|
- if bangqiu == '棒球':
|
|
|
- try:
|
|
|
- if pt == 1:
|
|
|
- Competition_sql = "insert into st_bq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_today,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_today=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time, 1, us_time, number, n_time, 1))
|
|
|
- if pt == 2:
|
|
|
- Competition_sql = "insert into st_bq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_morningplate,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_morningplate=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time,1, us_time, number, n_time, 1))
|
|
|
- if pt == 3:
|
|
|
- Competition_sql = "insert into st_bq_competition(home_team, guest_team, lg_id, match_id, match_date, match_time,ctime, utime, tag,source,expire_time,is_stringscene,us_time) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s,%s) on conflict(match_id) do update set tag = %s,expire_time=%s,is_stringscene=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (
|
|
|
- team_home, team_guest, league_id, game_id, match_date, match_time, utime, utime, number, "hg3535",
|
|
|
- n_time,1, us_time, number, n_time, 1))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球st_bq_competition插入错误')
|
|
|
- logger.warning(e)
|
|
|
+ payload_capots = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "odds",
|
|
|
+ "data": {
|
|
|
+ "match_id": game_id,
|
|
|
+ "lg_id": league_id,
|
|
|
+ "odds_code": key,
|
|
|
+ "status": 0,
|
|
|
+ "sort": 0,
|
|
|
+ "p_code": "capot",
|
|
|
+ "odds": value,
|
|
|
+ "condition": None,
|
|
|
+ "odds_only": odds_only,
|
|
|
+ "sole": new_hash,
|
|
|
+ "source": "hg3535",
|
|
|
+ "type": 0,
|
|
|
+ "team": ""
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload_capots)})
|
|
|
+ print(json.dumps(payload_capots))
|
|
|
+ print(resp.text, '棒球独赢')
|
|
|
return item
|
|
|
|
|
|
- def close_spider(self, spider):
|
|
|
- self.conn.commit()
|
|
|
- self.conn.close()
|
|
|
-
|
|
|
-
|
|
|
# 足球 篮球 网球 棒球 冠军------------------------------------------------------------------------------------------------
|
|
|
class Guanjunpipeline(object):
|
|
|
def process_item(self, item, spider):
|
|
|
@@ -1012,45 +1185,22 @@ class Guanjunpipeline(object):
|
|
|
s_hash = hash_func(league_id, league_name, ball, 0)
|
|
|
url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
if ball == "足球":
|
|
|
- payload1 = {
|
|
|
- "game_code": "zq",
|
|
|
- "title": "league",
|
|
|
- "data": {
|
|
|
- "name_chinese": league_name,
|
|
|
- "kind": "1",
|
|
|
- "match_mode": "1",
|
|
|
- "if_stop": "0",
|
|
|
- "belong": " ",
|
|
|
- "last_time": "2019-01-01 00:00:00",
|
|
|
- "lg_id": league_id,
|
|
|
- "source": "hg3535"
|
|
|
- }
|
|
|
- }
|
|
|
- resp = requests.post(url, data={"data": json.dumps(payload1)})
|
|
|
- print(resp.json())
|
|
|
n_gameid = int('1' + str(league_id))
|
|
|
- payload2 = {
|
|
|
+ payload = {
|
|
|
"game_code": "zq",
|
|
|
"title": "competition",
|
|
|
"data": {
|
|
|
"home_team": league_name,
|
|
|
- "guest_team": " ",
|
|
|
"lg_id": league_id,
|
|
|
"status": 0,
|
|
|
"match_id": n_gameid,
|
|
|
- "match_date": " ",
|
|
|
- "match_time": " ",
|
|
|
- "tag": " ",
|
|
|
"source": "hg3535",
|
|
|
- "is_rollball": 0,
|
|
|
- "is_today": 0,
|
|
|
- "is_morningplate": 0,
|
|
|
- "is_stringscene": 0,
|
|
|
"us_time": data_game
|
|
|
}
|
|
|
}
|
|
|
- resp1 = requests.post(url, data={"data": json.dumps(payload2)})
|
|
|
- print(resp1.json())
|
|
|
+ print(json.dumps(payload))
|
|
|
+ resp = requests.post(url, data={"data": json.dumps(payload)})
|
|
|
+ print(resp.text)
|
|
|
return item
|
|
|
# data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
# 'champion_team': champion_team, "p_id": 8, 'new_league_name': new_league_name,
|
|
|
@@ -1157,7 +1307,7 @@ class Liansaipipeline(object):
|
|
|
"kind": "1",
|
|
|
"match_mode": "1",
|
|
|
"if_stop": "0",
|
|
|
- "belong": "中国",
|
|
|
+ "belong": " ",
|
|
|
"last_time": "2019-01-01 00:00:00",
|
|
|
"lg_id": st_league,
|
|
|
"source": "hg3535"
|
|
|
@@ -1206,7 +1356,7 @@ class Liansaipipeline(object):
|
|
|
"kind": "1",
|
|
|
"match_mode": "1",
|
|
|
"if_stop": "0",
|
|
|
- "belong": "中国",
|
|
|
+ "belong": " ",
|
|
|
"last_time": "2019-01-01 00:00:00",
|
|
|
"lg_id": st_league,
|
|
|
"source": "hg3535"
|
|
|
@@ -1255,7 +1405,7 @@ class Liansaipipeline(object):
|
|
|
"kind": "1",
|
|
|
"match_mode": "1",
|
|
|
"if_stop": "0",
|
|
|
- "belong": "中国",
|
|
|
+ "belong": " ",
|
|
|
"last_time": "2019-01-01 00:00:00",
|
|
|
"lg_id": st_league,
|
|
|
"source": "hg3535"
|
|
|
@@ -1304,7 +1454,7 @@ class Liansaipipeline(object):
|
|
|
"kind": "1",
|
|
|
"match_mode": "1",
|
|
|
"if_stop": "0",
|
|
|
- "belong": "中国",
|
|
|
+ "belong": " ",
|
|
|
"last_time": "2019-01-01 00:00:00",
|
|
|
"lg_id": st_league,
|
|
|
"source": "hg3535"
|