|
|
@@ -24,7 +24,6 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
start_urls = ['https://hg3535z.com/odds2/d/getodds?sid=1&pt=4&ubt=am&pn=0&sb=2&dc=null&pid=0'] # 滚球菜单 足球滚球列url
|
|
|
|
|
|
|
|
|
-
|
|
|
def parse(self, response):
|
|
|
datas = json.loads(response.text)
|
|
|
# item = Today_all()
|
|
|
@@ -92,43 +91,18 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
concedes = data['o']['ah']['v']
|
|
|
new_concedes = [concedes[i] for i in range(len(concedes)) if i % 2 == 1]
|
|
|
concede_homes = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 == 0]
|
|
|
- # concede_home_rule = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 == 0]
|
|
|
- concede_home_rule = []
|
|
|
- for i in range(len(concede_homes)):
|
|
|
- if i % 2 is 0:
|
|
|
- home_rule = str(concede_homes[i])
|
|
|
- if home_rule.startswith('+'):
|
|
|
- n_home_rule = home_rule.replace('+', '-')
|
|
|
- concede_home_rule.append(n_home_rule)
|
|
|
- elif home_rule.startswith('-'):
|
|
|
- n_home_rule = home_rule.replace('-', '+')
|
|
|
- concede_home_rule.append(n_home_rule)
|
|
|
- else:
|
|
|
- concede_home_rule.append(home_rule)
|
|
|
- # concede_homes[i]
|
|
|
- # concede_home
|
|
|
+ concede_home_rule = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 == 0]
|
|
|
if pt is 3:
|
|
|
- concede_home = [float(concede_homes[i]) - 1 for i in range(len(concede_homes)) if i % 2 is 1]
|
|
|
+ concede_home = [round(float(concede_homes[i]) - 1, 2) for i in range(len(concede_homes)) if i % 2 is 1]
|
|
|
else:
|
|
|
concede_home = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 is 1]
|
|
|
|
|
|
concede_guests = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 is 1]
|
|
|
# concede_guest_rule
|
|
|
# concede_guest
|
|
|
- concede_guest_rule = []
|
|
|
- for i in range(len(concede_guests)):
|
|
|
- if i % 2 is 0:
|
|
|
- guest_rule = str(concede_guests[i])
|
|
|
- if guest_rule.startswith('+'):
|
|
|
- n_guest_rule = guest_rule.replace('+', '-')
|
|
|
- concede_guest_rule.append(n_guest_rule)
|
|
|
- elif guest_rule.startswith('-'):
|
|
|
- n_guest_rule = guest_rule.replace('-', '+')
|
|
|
- concede_guest_rule.append(n_guest_rule)
|
|
|
- else:
|
|
|
- concede_guest_rule.append(guest_rule)
|
|
|
+ concede_guest_rule = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 == 0]
|
|
|
if pt is 3:
|
|
|
- concede_guest = [float(concede_guests[i]) -1 for i in range(len(concede_guests)) if i % 2 is 1]
|
|
|
+ concede_guest = [round(float(concede_guests[i]) - 1, 2) for i in range(len(concede_guests)) if i % 2 is 1]
|
|
|
else:
|
|
|
concede_guest = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 is 1]
|
|
|
except:
|
|
|
@@ -143,39 +117,17 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
new_half_concedes = [half_concedes[i] for i in range(len(half_concedes)) if i % 2 is 1]
|
|
|
new_half_concede_homes = [new_half_concedes[i] for i in range(len(new_half_concedes)) if
|
|
|
i % 2 is 0]
|
|
|
- half_concede_home_rule = []
|
|
|
- for i in range(len(new_half_concede_homes)):
|
|
|
- if i % 2 == 0:
|
|
|
- home_rule = str(new_half_concede_homes[i])
|
|
|
- if home_rule.startswith('+'):
|
|
|
- n_home_rule = home_rule.replace('+', '-')
|
|
|
- half_concede_home_rule.append(n_home_rule)
|
|
|
- if home_rule.startswith('-'):
|
|
|
- n_home_rule = home_rule.replace('-', '+')
|
|
|
- half_concede_home_rule.append(n_home_rule)
|
|
|
- else:
|
|
|
- half_concede_home_rule.append(home_rule)
|
|
|
+ half_concede_guest_rule = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 == 0]
|
|
|
# concede_home
|
|
|
if pt is 3:
|
|
|
- half_concede_home = [float(new_half_concede_homes[i]) - 1 for i in range(len(new_half_concede_homes)) if i % 2 is 1]
|
|
|
+ half_concede_home = [round(float(new_half_concede_homes[i]) - 1, 2) for i in range(len(new_half_concede_homes)) if i % 2 is 1]
|
|
|
else:
|
|
|
half_concede_home = [new_half_concede_homes[i] for i in range(len(new_half_concede_homes)) if i % 2 is 1]
|
|
|
half_concede_guests = [new_half_concedes[i] for i in range(len(new_half_concedes)) if i % 2 is 1]
|
|
|
- half_concede_guest_rule = []
|
|
|
- for i in range(len(half_concede_guests)):
|
|
|
- if i % 2 == 0:
|
|
|
- guest_rule = str(half_concede_guests[i])
|
|
|
- if guest_rule.startswith('+'):
|
|
|
- n_guest_rule = guest_rule.replace('+', '-')
|
|
|
- half_concede_guest_rule.append(n_guest_rule)
|
|
|
- if guest_rule.startswith('-'):
|
|
|
- n_guest_rule = guest_rule.replace('-', '+')
|
|
|
- half_concede_guest_rule.append(n_guest_rule)
|
|
|
- else:
|
|
|
- half_concede_guest_rule.append(guest_rule)
|
|
|
+ half_concede_home_rule = [half_concede_guests[i] for i in range(len(half_concede_guests)) if i % 2 == 0]
|
|
|
# concede_guest
|
|
|
if pt is 3:
|
|
|
- half_concede_guest = [float(half_concede_guests[i]) -1 for i in range(len(half_concede_guests)) if
|
|
|
+ half_concede_guest = [round(float(half_concede_guests[i]) -1, 2) for i in range(len(half_concede_guests)) if
|
|
|
i % 2 is 1]
|
|
|
else:
|
|
|
half_concede_guest = [half_concede_guests[i] for i in range(len(half_concede_guests)) if
|
|
|
@@ -195,7 +147,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
size_home_rule = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 0]
|
|
|
# size_home
|
|
|
if pt is 3:
|
|
|
- size_home = [float(size_homes[i]) - 1 for i in range(len(size_homes)) if i % 2 is 1]
|
|
|
+ size_home = [round(float(size_homes[i]) - 1, 2) for i in range(len(size_homes)) if i % 2 is 1]
|
|
|
else:
|
|
|
size_home = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 1]
|
|
|
|
|
|
@@ -204,7 +156,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
size_guest_rule = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 0]
|
|
|
# csize_guest
|
|
|
if pt is 3:
|
|
|
- size_guest = [float(size_guests[i]) - 1 for i in range(len(size_guests)) if i % 2 is 1]
|
|
|
+ size_guest = [round(float(size_guests[i]) - 1, 2) for i in range(len(size_guests)) if i % 2 is 1]
|
|
|
else:
|
|
|
size_guest = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 1]
|
|
|
except:
|
|
|
@@ -223,7 +175,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
i % 2 is 0]
|
|
|
# half_size_home 主队
|
|
|
if pt is 3:
|
|
|
- half_size_home = [float(half_size_homes[i]) -1 for i in range(len(half_size_homes)) if i % 2 is 1]
|
|
|
+ half_size_home = [round(float(half_size_homes[i]) - 1, 2) for i in range(len(half_size_homes)) if i % 2 is 1]
|
|
|
else:
|
|
|
half_size_home = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 is 1]
|
|
|
half_size_guests = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 1]
|
|
|
@@ -232,7 +184,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
i % 2 is 0]
|
|
|
# half_size_guest
|
|
|
if pt is 3:
|
|
|
- half_size_guest = [float(half_size_guests[i]) - 1 for i in range(len(half_size_guests)) if
|
|
|
+ half_size_guest = [round(float(half_size_guests[i]) - 1, 2) for i in range(len(half_size_guests)) if
|
|
|
i % 2 is 1]
|
|
|
else:
|
|
|
half_size_guest = [half_size_guests[i] for i in range(len(half_size_guests)) if
|
|
|
@@ -248,10 +200,10 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
total_goals = data['o']['tg']['v']
|
|
|
new_total_goals = [total_goals[i] for i in range(len(total_goals)) if i % 2 is 1]
|
|
|
- total_goal["total_goal_zero"] = float(new_total_goals[0]) - 1
|
|
|
- total_goal["total_goal_two"] = float(new_total_goals[1]) - 1
|
|
|
- total_goal["total_goal_four"] = float(new_total_goals[2]) - 1
|
|
|
- total_goal["total_goal_seven"] = float(new_total_goals[3]) - 1
|
|
|
+ total_goal["total_goal_zero"] = round(float(new_total_goals[0]) - 1, 2)
|
|
|
+ total_goal["total_goal_two"] = round(float(new_total_goals[1]) - 1, 2)
|
|
|
+ total_goal["total_goal_four"] = round(float(new_total_goals[2]) - 1, 2)
|
|
|
+ total_goal["total_goal_seven"] = round(float(new_total_goals[3]) - 1, 2)
|
|
|
except:
|
|
|
total_goal["total_goal_zero"] = ""
|
|
|
total_goal["total_goal_two"] = ""
|
|
|
@@ -262,10 +214,10 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
half_total_goals = data['o']['tg1st']['v']
|
|
|
new_half_total_goals = [half_total_goals[i] for i in range(len(half_total_goals)) if i % 2 is 1]
|
|
|
- total_goal["half_total_goal_zero"] = float(new_half_total_goals[0]) - 1
|
|
|
- total_goal["half_total_goal_one"] = float(new_half_total_goals[1]) - 1
|
|
|
- total_goal["half_total_goal_two"] = float(new_half_total_goals[2]) - 1
|
|
|
- total_goal["half_total_goal_three"] = float(new_half_total_goals[3]) - 1
|
|
|
+ total_goal["half_total_goal_zero"] = round(float(new_half_total_goals[0]) - 1, 2)
|
|
|
+ total_goal["half_total_goal_one"] = round(float(new_half_total_goals[1]) - 1, 2)
|
|
|
+ total_goal["half_total_goal_two"] = round(float(new_half_total_goals[2]) - 1, 2)
|
|
|
+ total_goal["half_total_goal_three"] = round(float(new_half_total_goals[3]) - 1, 2)
|
|
|
except:
|
|
|
total_goal["half_total_goal_zero"] = ""
|
|
|
total_goal["half_total_goal_one"] = ""
|
|
|
@@ -282,7 +234,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
half_fulls = data['o']['hf']['v']
|
|
|
new_half_fulls = [half_fulls[i] for i in range(len(half_fulls)) if i % 2 is 1]
|
|
|
for index, value in enumerate(new_lists):
|
|
|
- half_full[value] = float(new_half_fulls[index]) - 1
|
|
|
+ half_full[value] = round(float(new_half_fulls[index]) - 1, 2)
|
|
|
except:
|
|
|
for index, value in enumerate(new_lists):
|
|
|
half_full[value] = ""
|
|
|
@@ -292,8 +244,8 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
first_balls = data['o']['ttslast']['v']
|
|
|
first_ball = [first_balls[i] for i in range(len(first_balls)) if i % 2 is 1]
|
|
|
- first_last_ball['first_ball_home'] = float(first_ball[0]) - 1
|
|
|
- first_last_ball['first_ball_guest'] = float(first_ball[1]) - 1
|
|
|
+ first_last_ball['first_ball_home'] = round(float(first_ball[0]) - 1, 2)
|
|
|
+ first_last_ball['first_ball_guest'] = round(float(first_ball[1]) - 1, 2)
|
|
|
except:
|
|
|
pass
|
|
|
|
|
|
@@ -302,9 +254,9 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
last_balls = data['o']['tts1st']['v']
|
|
|
last_ball = [last_balls[i] for i in range(len(last_balls)) if i % 2 is 1]
|
|
|
- first_last_ball['last_ball_home'] = float(last_ball[0]) - 1
|
|
|
- first_last_ball['last_ball_guest'] = float(last_ball[1]) - 1
|
|
|
- first_last_ball['not_ball'] = float(last_ball[2]) - 1
|
|
|
+ first_last_ball['last_ball_home'] = round(float(last_ball[0]) - 1, 2)
|
|
|
+ first_last_ball['last_ball_guest'] = round(float(last_ball[1]) - 1, 2)
|
|
|
+ first_last_ball['not_ball'] = round(float(last_ball[2]) - 1, 2)
|
|
|
except:
|
|
|
pass
|
|
|
|
|
|
@@ -313,9 +265,9 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
capots = data['o']['1x2']['v']
|
|
|
new_capots = [capots[i] for i in range(len(capots)) if i % 2 is 1]
|
|
|
- capot_home = float(new_capots[0]) - 1
|
|
|
- capot_guest = float(new_capots[1]) - 1
|
|
|
- capot_dogfall = float(new_capots[2]) - 1
|
|
|
+ capot_home = round(float(new_capots[0]) - 1, 2)
|
|
|
+ capot_guest = round(float(new_capots[1]) - 1, 2)
|
|
|
+ capot_dogfall = round(float(new_capots[2]) - 1, 2)
|
|
|
except:
|
|
|
capot_home = ""
|
|
|
capot_guest = ""
|
|
|
@@ -325,9 +277,9 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
try:
|
|
|
half_capots = data['o']['1x21st']['v']
|
|
|
new_half_capots = [half_capots[i] for i in range(len(half_capots)) if i % 2 is 1]
|
|
|
- half_capot_home = float(new_half_capots[0]) - 1
|
|
|
- half_capot_guest = float(new_half_capots[1]) - 1
|
|
|
- half_capot_dogfall = float(new_half_capots[2]) - 1
|
|
|
+ half_capot_home = round(float(new_half_capots[0]) - 1, 2)
|
|
|
+ half_capot_guest = round(float(new_half_capots[1]) - 1, 2)
|
|
|
+ half_capot_dogfall = round(float(new_half_capots[2]) - 1, 2)
|
|
|
except:
|
|
|
half_capot_home = ""
|
|
|
half_capot_guest = ""
|
|
|
@@ -371,16 +323,16 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
# 主队bodan_home
|
|
|
bodan_home = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 is 0]
|
|
|
for index, t in enumerate(one_list):
|
|
|
- bodan_data[t] = float(bodan_home[index]) - 1
|
|
|
+ bodan_data[t] = round(float(bodan_home[index]) - 1, 2)
|
|
|
# 客队bodan_guest
|
|
|
bodan_guest = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 is 1]
|
|
|
for y, z in enumerate(two_list):
|
|
|
- bodan_data[z] = float(bodan_guest[y]) - 1
|
|
|
+ bodan_data[z] = round(float(bodan_guest[y]) - 1, 2)
|
|
|
bodan_dogfall = new_bodans[-7:-2]
|
|
|
for a, b in enumerate(three_list):
|
|
|
- bodan_data[b] = float(bodan_dogfall[a]) - 1
|
|
|
+ bodan_data[b] = round(float(bodan_dogfall[a]) - 1, 2)
|
|
|
# 其他bodan_other
|
|
|
- bodan_data['bodanother'] = float(new_bodans[-1]) - 1
|
|
|
+ bodan_data['bodanother'] = round(float(new_bodans[-1]) - 1, 2)
|
|
|
except:
|
|
|
pass
|
|
|
|
|
|
@@ -398,17 +350,17 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
half_bodan_home = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 is 0]
|
|
|
# 队1
|
|
|
for index, t in enumerate(new_one):
|
|
|
- bodan_data[t] = float(half_bodan_home[index]) - 1
|
|
|
+ bodan_data[t] = round(float(half_bodan_home[index]) - 1, 2)
|
|
|
# 队2
|
|
|
half_bodan_guest = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 is 1]
|
|
|
for y, z in enumerate(new_two):
|
|
|
- bodan_data[z] = float(half_bodan_guest[y]) - 1
|
|
|
+ bodan_data[z] = round(float(half_bodan_guest[y]) - 1, 2)
|
|
|
# 和/平
|
|
|
half_bodan_dogfall = new_half_bodans[-6:-2]
|
|
|
for a, b in enumerate(new_three):
|
|
|
- bodan_data[b] = float(half_bodan_dogfall[a]) - 1
|
|
|
+ bodan_data[b] = round(float(half_bodan_dogfall[a]) - 1, 2)
|
|
|
# 其他
|
|
|
- bodan_data['halfbodanother'] = float(new_half_bodans[-1]) - 1
|
|
|
+ bodan_data['halfbodanother'] = round(float(new_half_bodans[-1]) - 1, 2)
|
|
|
except:
|
|
|
pass
|
|
|
if new_data == 12:
|