|
|
@@ -2,8 +2,10 @@ import json
|
|
|
import time
|
|
|
import redis
|
|
|
import logging
|
|
|
-# import requests
|
|
|
+import requests
|
|
|
+import scrapy
|
|
|
# from twisted.enterprise import adbapi
|
|
|
+from requests import Request
|
|
|
from scrapy.conf import settings
|
|
|
import psycopg2
|
|
|
import psycopg2.extras
|
|
|
@@ -61,7 +63,7 @@ class Zuqiupipeline(object):
|
|
|
number = item['number']
|
|
|
pt = item['pt']
|
|
|
corner_ball = item['corner_ball']
|
|
|
- p_code, p_id = get_pcode(corner_ball, 'concede_size')
|
|
|
+ p_code, p_id = get_pcode(corner_ball, 'goal_size')
|
|
|
# 构建唯一索引
|
|
|
half_size_guest = item["half_size_guest"]
|
|
|
half_size_guest_rule = item["half_size_guest_rule"]
|
|
|
@@ -73,7 +75,7 @@ class Zuqiupipeline(object):
|
|
|
'source': "hg3535", 'expire_time': expire_time, 'pt': pt}
|
|
|
# 让球 数据插入数据库
|
|
|
try:
|
|
|
- zqone_intodb(data1=half_size_home, data2=size_data, data3="half_size_home", data4=half_size_home_rule,
|
|
|
+ zqone_intodb(data1=half_size_home, data2=size_data, data3="half_goal_size_home", data4=half_size_home_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球half_size_home插入错误')
|
|
|
@@ -81,7 +83,7 @@ class Zuqiupipeline(object):
|
|
|
# print(item)
|
|
|
# # 让球 数据插入数据库
|
|
|
try:
|
|
|
- zqone_intodb(data1=half_size_guest, data2=size_data, data3="half_size_guest", data4=half_size_guest_rule,
|
|
|
+ zqone_intodb(data1=half_size_guest, data2=size_data, data3="half_goal_size_guest", data4=half_size_guest_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球half_size_guest插入错误')
|
|
|
@@ -92,17 +94,20 @@ class Zuqiupipeline(object):
|
|
|
size_home = item["size_home"]
|
|
|
size_home_rule = item["size_home_rule"]
|
|
|
try:
|
|
|
- zqone_intodb(data1=size_guest, data2=size_data, data3="size_guest", data4=size_guest_rule,
|
|
|
+ zqone_intodb(data1=size_guest, data2=size_data, data3="goal_size_guest", data4=size_guest_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球size_guest插入错误')
|
|
|
logger.warning(e)
|
|
|
try:
|
|
|
- zqone_intodb(data1=size_home, data2=size_data, data3="size_home", data4=size_home_rule,
|
|
|
+ zqone_intodb(data1=size_home, data2=size_data, data3="goal_size_home", data4=size_home_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球size_home插入错误')
|
|
|
logger.warning(e)
|
|
|
+ p_code, p_id = get_pcode(corner_ball, 'concede')
|
|
|
+ concede_data = {'league_id': league_id, 'game_id': competition_id, 'utime': utime, 'p_id': p_id, 'p_code': p_code,
|
|
|
+ 'source': "hg3535", 'expire_time': expire_time, 'pt': pt}
|
|
|
# 上半场大小
|
|
|
half_concede_home_rule = item["half_concede_home_rule"]
|
|
|
half_concede_home = item["half_concede_home"]
|
|
|
@@ -110,13 +115,13 @@ class Zuqiupipeline(object):
|
|
|
half_concede_guest = item["half_concede_guest"]
|
|
|
# 上半场让球
|
|
|
try:
|
|
|
- zqone_intodb(data1=half_concede_home, data2=size_data, data3="half_concede_home", data4=half_concede_home_rule,
|
|
|
+ zqone_intodb(data1=half_concede_home, data2=concede_data, data3="half_concede_home", data4=half_concede_home_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球half_concede_home插入错误')
|
|
|
logger.warning(e)
|
|
|
try:
|
|
|
- zqone_intodb(data1=half_concede_guest, data2=size_data, data3="half_concede_guest", data4=half_concede_guest_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
+ zqone_intodb(data1=half_concede_guest, data2=concede_data, data3="half_concede_guest", data4=half_concede_guest_rule, cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球half_concede_guest插入错误')
|
|
|
logger.warning(e)
|
|
|
@@ -126,18 +131,18 @@ class Zuqiupipeline(object):
|
|
|
concede_home_rule = item["concede_home_rule"]
|
|
|
# 全场让球
|
|
|
try:
|
|
|
- zqone_intodb(data1=concede_guest, data2=size_data, data3="concede_guest", data4=concede_guest_rule,
|
|
|
+ zqone_intodb(data1=concede_guest, data2=concede_data, data3="concede_guest", data4=concede_guest_rule,
|
|
|
cursor=self.cursor, redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球concede_guest插入错误')
|
|
|
logger.warning(e)
|
|
|
try:
|
|
|
- zqone_intodb(data1=concede_home, data2=size_data, data3="concede_home", data4=concede_home_rule,
|
|
|
+ zqone_intodb(data1=concede_home, data2=concede_data, data3="concede_home", data4=concede_home_rule,
|
|
|
cursor=self.cursor,redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
logger.warning('足球concede_home插入错误')
|
|
|
logger.warning(e)
|
|
|
- #
|
|
|
+
|
|
|
p_code, p_id = get_pcode(corner_ball, 'capot')
|
|
|
# 独赢----------------------------------------------------------------------------------------------------------
|
|
|
half_capot_home = item["half_capot_home"]
|
|
|
@@ -203,6 +208,30 @@ class Zuqiupipeline(object):
|
|
|
except Exception as e:
|
|
|
logger.warning('足球odd_even_odd插入错误')
|
|
|
logger.warning(e)
|
|
|
+ # url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
+ # data = {
|
|
|
+ # "game_code": "zq",
|
|
|
+ # "title": "odds",
|
|
|
+ # "data": {
|
|
|
+ # "match_id": competition_id,
|
|
|
+ # "lg_id": 1123,
|
|
|
+ # "odds_code": "concede_guest",
|
|
|
+ # "status": 0,
|
|
|
+ # "sort": 0,
|
|
|
+ # "p_code": "concede_size",
|
|
|
+ # "odds": 1.2333,
|
|
|
+ # "condition": "+1.5",
|
|
|
+ # "odds_only": "b15bad3fc8f09924874fef0e19f63d001",
|
|
|
+ # "sole": "5e2225944d8cdc44cd7943330986978d2",
|
|
|
+ # "source": "c22123",
|
|
|
+ # "type": 0,
|
|
|
+ # "team": ""
|
|
|
+ # }
|
|
|
+ # }
|
|
|
+ # data = json.dumps(data)
|
|
|
+ # print(data)
|
|
|
+ # r = requests.post(url, data=data)
|
|
|
+ # print(r.content)
|
|
|
try:
|
|
|
zqtwo_intodb(data1=odd_even_even, data2=two_sides_data, data3="two_sides_double", data4='双', cursor=self.cursor,redis_db=self.redis_db)
|
|
|
except Exception as e:
|
|
|
@@ -314,7 +343,7 @@ class Zuqiupipeline(object):
|
|
|
logger.warning('足球first_last_balls插入错误')
|
|
|
logger.warning(e)
|
|
|
|
|
|
- p_code, p_id = get_pcode(corner_ball, 'temaball')
|
|
|
+ p_code, p_id = get_pcode(corner_ball, 'team_score')
|
|
|
full_dicts = item['full_data']
|
|
|
half_dicts = item['half_data']
|
|
|
full_dict_rules = item['full_data_rule']
|
|
|
@@ -952,14 +981,6 @@ class Bangqiupipeline(object):
|
|
|
|
|
|
# 足球 篮球 网球 棒球 冠军------------------------------------------------------------------------------------------------
|
|
|
class Guanjunpipeline(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__)
|
|
|
data_game = item['data_game'].replace('年', "-").replace('月', "-").replace('日', "")
|
|
|
@@ -989,81 +1010,115 @@ class Guanjunpipeline(object):
|
|
|
r_hash = hash_func(league_id, new_champion, tema_home, champion_team)
|
|
|
odds_only = r_hash
|
|
|
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))
|
|
|
- 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,
|
|
|
- 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
- "odds_only": odds_only,
|
|
|
- "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
- try:
|
|
|
- gjz_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
- Competition_sql = "insert into st_zq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('足球冠军插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- elif ball == "篮球":
|
|
|
- n_gameid = int('2' + str(league_id))
|
|
|
- data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
- 'champion_team': champion_team, "p_id": 7, 'new_league_name': new_league_name,
|
|
|
- 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
- "odds_only": odds_only,
|
|
|
- "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
- try:
|
|
|
- gjl_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
- Competition_sql = "insert into st_lq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('篮球冠军插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- elif ball == "网球":
|
|
|
- n_gameid = int('3' + str(league_id))
|
|
|
- data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
- 'champion_team': champion_team, "p_id": 6, 'new_league_name': new_league_name,
|
|
|
- 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
- "odds_only": odds_only,
|
|
|
- "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
- try:
|
|
|
- gjw_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
- Competition_sql = "insert into st_wq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('网球冠军插入错误')
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
-
|
|
|
- elif ball == "棒球":
|
|
|
- n_gameid = int('4' + str(league_id))
|
|
|
- data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
- 'champion_team': champion_team, "p_id": 5, 'new_league_name': new_league_name,
|
|
|
- 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
- "odds_only": odds_only,
|
|
|
- "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
- try:
|
|
|
- gjb_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
- Competition_sql = "insert into st_bq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
- self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
- except Exception as e:
|
|
|
- logger.warning('棒球冠军插入错误')
|
|
|
- logger.warning(e)
|
|
|
- return item
|
|
|
-
|
|
|
- def close_spider(self, spider):
|
|
|
- self.conn.commit()
|
|
|
- self.conn.close()
|
|
|
+ payload2 = {
|
|
|
+ "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())
|
|
|
+ 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,
|
|
|
+ # 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
+ # "odds_only": odds_only,
|
|
|
+ # "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
+ # try:
|
|
|
+ # gjz_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
+ # Competition_sql = "insert into st_zq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('足球冠军插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ #
|
|
|
+ # elif ball == "篮球":
|
|
|
+ # n_gameid = int('2' + str(league_id))
|
|
|
+ # data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
+ # 'champion_team': champion_team, "p_id": 7, 'new_league_name': new_league_name,
|
|
|
+ # 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
+ # "odds_only": odds_only,
|
|
|
+ # "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
+ # try:
|
|
|
+ # gjl_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
+ # Competition_sql = "insert into st_lq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('篮球冠军插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ #
|
|
|
+ # elif ball == "网球":
|
|
|
+ # n_gameid = int('3' + str(league_id))
|
|
|
+ # data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
+ # 'champion_team': champion_team, "p_id": 6, 'new_league_name': new_league_name,
|
|
|
+ # 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
+ # "odds_only": odds_only,
|
|
|
+ # "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
+ # try:
|
|
|
+ # gjw_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
+ # Competition_sql = "insert into st_wq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('网球冠军插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ #
|
|
|
+ #
|
|
|
+ # elif ball == "棒球":
|
|
|
+ # n_gameid = int('4' + str(league_id))
|
|
|
+ # data_dict = {'league_id': league_id, 'new_champion': new_champion, 'utime': utime,
|
|
|
+ # 'champion_team': champion_team, "p_id": 5, 'new_league_name': new_league_name,
|
|
|
+ # 'tema_home': tema_home, 'new_hash': new_hash, 'expire_time': expire_time,
|
|
|
+ # "odds_only": odds_only,
|
|
|
+ # "league_name": league_name, 'time3': time3, 'game_id': n_gameid}
|
|
|
+ # try:
|
|
|
+ # gjb_into(data_dict, self.cursor, r_hash, s_hash, self.redis_db)
|
|
|
+ # Competition_sql = "insert into st_bq_competition(home_team, lg_id, match_id, ctime, utime, source, us_time) values (%s, %s, %s, %s, %s, %s, %s) on conflict(match_id) do update set utime=%s;"
|
|
|
+ # self.cursor.execute(Competition_sql, (league_name, league_id, n_gameid, utime, utime, 'hg3535', data_game, utime))
|
|
|
+ # except Exception as e:
|
|
|
+ # logger.warning('棒球冠军插入错误')
|
|
|
+ # logger.warning(e)
|
|
|
+ # return item
|
|
|
+ #
|
|
|
+ # def close_spider(self, spider):
|
|
|
+ # self.conn.commit()
|
|
|
+ # self.conn.close()
|
|
|
|
|
|
|
|
|
# 足球 篮球 网球 棒球 联赛------------------------------------------------------------------------------------------------
|
|
|
class Liansaipipeline(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__)
|
|
|
area_id = item["area_id"]
|
|
|
@@ -1071,94 +1126,208 @@ class Liansaipipeline(object):
|
|
|
st_league = item["st_league"]
|
|
|
name_chinese = item["name_chinese"]
|
|
|
ball = item['ball']
|
|
|
- utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
+ # utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
|
|
area_dict = {"南美洲": 3, "北美洲": 4, "欧洲": 5, "大洋洲": 6, "南极洲": 7, "非洲": 1, "世界": 8, "亚洲": 2}
|
|
|
- redis_data_dict = "hg3535_liansai"
|
|
|
- r_hash = hash_func(st_league, name_chinese, ball, 0)
|
|
|
- if self.redis_db.hexists(redis_data_dict, r_hash):
|
|
|
- pass
|
|
|
- else:
|
|
|
- self.redis_db.hset(redis_data_dict, r_hash, 0)
|
|
|
- if ball == "足球":
|
|
|
- try:
|
|
|
- if area_name in area_dict:
|
|
|
- sql1 = "insert into st_zq_league(name_chinese, lg_id, area_id,source,utime) values (%s, %s, %s, %s, %s) on conflict(lg_id) do update set area_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql1, (name_chinese, st_league, area_dict[area_name], "hg3535",utime, area_dict[area_name], "hg3535"))
|
|
|
- else:
|
|
|
- if area_name == "足球":
|
|
|
- sql2 = "insert into st_zq_league(name_chinese, lg_id, country_id,source) values (%s, %s, %s, %s) on conflict(lg_id) do update set source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, 0, "hg3535", "hg3535"))
|
|
|
- else:
|
|
|
- sql2 = "insert into st_zq_league(name_chinese, lg_id, country_id,source,utime) values (%s, %s, %s, %s, %s) on conflict(lg_id) do update set country_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, area_id, "hg3535",utime, area_id, "hg3535"))
|
|
|
-
|
|
|
- sql3 = "insert into st_country(country_id, name_chinese, country_area, country_order,recommend_order, update_time,source) values (%s, %s, %s,%s, %s, %s,%s) on conflict(country_id) do update set update_time =%s,source=%s;"
|
|
|
- self.cursor.execute(sql3, (area_id, area_name, 0, 0, 0, utime, "hg3535", utime, "hg3535"))
|
|
|
- except Exception as e:
|
|
|
- logger.warning("足球联赛插入错误")
|
|
|
- logger.warning(e)
|
|
|
-
|
|
|
- elif ball == "篮球":
|
|
|
- try:
|
|
|
- if area_name in area_dict:
|
|
|
- sql1 = "insert into st_lq_league(name_chinese, lg_id, area_id,source,utime) values (%s, %s, %s,%s,%s) on conflict(lg_id) do update set area_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql1,
|
|
|
- (name_chinese, st_league, area_dict[area_name], "hg3535",utime, area_dict[area_name],"hg3535"))
|
|
|
- else:
|
|
|
- if area_name == "篮球":
|
|
|
- sql2 = "insert into st_lq_league(name_chinese, lg_id, country_id,source) values (%s, %s, %s, %s) on conflict(lg_id) do update set source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, 0, "hg3535", "hg3535"))
|
|
|
- else:
|
|
|
- sql2 = "insert into st_lq_league(name_chinese, lg_id, country_id,source,utime) values (%s, %s, %s, %s, %s) on conflict(lg_id) do update set country_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, area_id, "hg3535",utime, area_id, "hg3535"))
|
|
|
-
|
|
|
- sql3 = "insert into st_country(country_id, name_chinese, country_area, country_order,recommend_order, update_time,source) values (%s, %s, %s,%s, %s, %s,%s) on conflict(country_id) do update set update_time =%s,source=%s;"
|
|
|
- self.cursor.execute(sql3, (area_id, area_name, 0, 0, 0, utime, "hg3535", utime, "hg3535"))
|
|
|
- except Exception as e:
|
|
|
- logger.warning("篮球联赛插入错误")
|
|
|
- logger.warning(e)
|
|
|
- elif ball == "网球":
|
|
|
- try:
|
|
|
- if area_name in area_dict:
|
|
|
- sql1 = "insert into st_wq_league(name_chinese, lg_id, area_id,source,utime) values (%s, %s, %s,%s,%s) on conflict(lg_id) do update set area_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql1, (name_chinese, st_league, area_dict[area_name], "hg3535",utime, area_dict[area_name],"hg3535"))
|
|
|
- else:
|
|
|
- if area_name == "网球":
|
|
|
- sql2 = "insert into st_wq_league(name_chinese, lg_id, country_id,source) values (%s, %s, %s,%s) on conflict(lg_id) do update set source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, 0, "hg3535", "hg3535"))
|
|
|
- else:
|
|
|
- sql2 = "insert into st_wq_league(name_chinese, lg_id, country_id,source,utime) values (%s, %s, %s,%s,%s) on conflict(lg_id) do update set country_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, area_id, "hg3535",utime, area_id, "hg3535"))
|
|
|
-
|
|
|
- sql3 = "insert into st_country(country_id, name_chinese, country_area, country_order,recommend_order, update_time,source) values (%s, %s, %s,%s, %s, %s,%s) on conflict(country_id) do update set update_time =%s,source=%s;"
|
|
|
- self.cursor.execute(sql3, (area_id, area_name, 0, 0, 0, utime, "hg3535", utime, "hg3535"))
|
|
|
- except Exception as e:
|
|
|
- logger.warning("网球联赛插入错误")
|
|
|
- logger.warning(e)
|
|
|
- elif ball == "棒球":
|
|
|
- try:
|
|
|
- if area_name in area_dict:
|
|
|
- sql1 = "insert into st_bq_league(name_chinese, lg_id, area_id,source,utime) values (%s, %s, %s,%s,%s) on conflict(lg_id) do update set area_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql1,(name_chinese, st_league, area_dict[area_name], "hg3535",utime, area_dict[area_name],"hg3535"))
|
|
|
- else:
|
|
|
- if area_name == "棒球":
|
|
|
- sql2 = "insert into st_bq_league(name_chinese, lg_id, country_id,source) values (%s, %s, %s,%s) on conflict(lg_id) do update set source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, 0, "hg3535", "hg3535"))
|
|
|
- else:
|
|
|
- sql2 = "insert into st_bq_league(name_chinese, lg_id, country_id,source,utime) values (%s, %s, %s,%s,%s) on conflict(lg_id) do update set country_id = %s,source=%s;"
|
|
|
- self.cursor.execute(sql2, (name_chinese, st_league, area_id, "hg3535",utime, area_id, "hg3535"))
|
|
|
-
|
|
|
- sql3 = "insert into st_country(country_id, name_chinese, country_area, country_order,recommend_order, update_time,source) values (%s, %s, %s,%s, %s, %s,%s) on conflict(country_id) do update set update_time =%s,source=%s;"
|
|
|
- self.cursor.execute(sql3, (area_id, area_name, 0, 0, 0, utime, "hg3535", utime, "hg3535"))
|
|
|
- except Exception as e:
|
|
|
- logger.warning("棒球联赛插入错误")
|
|
|
- logger.warning(e)
|
|
|
- return item
|
|
|
-
|
|
|
- def close_spider(self, spider):
|
|
|
- self.conn.commit()
|
|
|
- self.conn.close()
|
|
|
-
|
|
|
+ # redis_data_dict = "hg3535_liansai"
|
|
|
+ # r_hash = hash_func(st_league, name_chinese, ball, 0)
|
|
|
+ url = 'http://sports.5gogo.com/Sports/WriteSports/setSports'
|
|
|
+ if ball == "足球":
|
|
|
+ if area_name in area_dict:
|
|
|
+ payload = {
|
|
|
+ "game_code": "zq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": area_name,
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ if area_name == "足球":
|
|
|
+ payload = {
|
|
|
+ "game_code": "zq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": "中国",
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ payload = {
|
|
|
+ "game_code": "zq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": 'area_name',
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }}
|
|
|
+ data = {"data": json.dumps(payload)}
|
|
|
+ resp = requests.post(url, data=data)
|
|
|
+ print(resp.text)
|
|
|
+ elif ball == "篮球":
|
|
|
+ if area_name in area_dict:
|
|
|
+ payload = {
|
|
|
+ "game_code": "lq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": area_name,
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ if area_name == "篮球":
|
|
|
+ payload = {
|
|
|
+ "game_code": "lq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": "中国",
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ payload = {
|
|
|
+ "game_code": "lq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": 'area_name',
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }}
|
|
|
+ data = {"data": json.dumps(payload)}
|
|
|
+ resp = requests.post(url, data=data)
|
|
|
+ print(resp.text)
|
|
|
+ elif ball == "网球":
|
|
|
+ if area_name in area_dict:
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": area_name,
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ if area_name == "网球":
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": "中国",
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ payload = {
|
|
|
+ "game_code": "wq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": 'area_name',
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }}
|
|
|
+ data = {"data": json.dumps(payload)}
|
|
|
+ resp = requests.post(url, data=data)
|
|
|
+ print(resp.text)
|
|
|
+ elif ball == "棒球":
|
|
|
+ if area_name in area_dict:
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": area_name,
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ if area_name == "棒球":
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": "中国",
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else:
|
|
|
+ payload = {
|
|
|
+ "game_code": "bq",
|
|
|
+ "title": "league",
|
|
|
+ "data": {
|
|
|
+ "name_chinese": name_chinese,
|
|
|
+ "kind": "1",
|
|
|
+ "match_mode": "1",
|
|
|
+ "if_stop": "0",
|
|
|
+ "belong": 'area_name',
|
|
|
+ "last_time": "2019-01-01 00:00:00",
|
|
|
+ "lg_id": st_league,
|
|
|
+ "source": "hg3535"
|
|
|
+ }}
|
|
|
+ data = {"data": json.dumps(payload)}
|
|
|
+ resp = requests.post(url, data=data)
|
|
|
+ print(resp.text)
|
|
|
+ return item
|
|
|
|
|
|
# ---------------------------------------------------------滚球---------------------------------------------------------
|
|
|
# 滚球足球 插入
|
|
|
@@ -1811,15 +1980,15 @@ class Roll_Banqiupipeline(object):
|
|
|
# 让球
|
|
|
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}
|
|
|
- # bqone_intodb(data1=concedes_dict, data2=concede, data3=concedes_dict_rule, cursor=cursor)
|
|
|
+ # bqone_intodb(data1=concedes_dict, data2=concede, data3=concedes_dict_rule, cursor=self.cursor)
|
|
|
# 总得分:大/小
|
|
|
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}
|
|
|
- # bqone_intodb(data1=total_size_dict, data2=total_size, data3=total_size_dict_rule, cursor=cursor)
|
|
|
+ # bqone_intodb(data1=total_size_dict, data2=total_size, data3=total_size_dict_rule, cursor=self.cursor)
|
|
|
|
|
|
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}
|
|
|
- # bqone_intodb(data1=odd_evens_dict, data2=odd_even, data3=odd_evens_dict_rule, cursor=cursor)
|
|
|
+ # bqone_intodb(data1=odd_evens_dict, data2=odd_even, data3=odd_evens_dict_rule, cursor=self.cursor)
|
|
|
# 赛事失效时间
|
|
|
# n_time = out_time(ctime, 3.5)
|
|
|
# 插入独赢
|