Your Name 6 年之前
父節點
當前提交
fc23e7da43

二進制
hg3535/spiders/__pycache__/roll_zuqiu.cpython-36.pyc


+ 18 - 18
hg3535/spiders/roll_bangqiu.py

@@ -152,27 +152,27 @@ class BqrangqiuSpider(scrapy.Spider):
                     total_size_dict_rule = {}
                     try:
                         total_sizes = result['o']["ou"]["v"]
-                        total_size_dict_rule['total_size_big'] = total_sizes[1]
-                        total_size_dict['total_size_big'] = total_sizes[5]
-                        total_size_dict_rule['total_size_small'] = total_sizes[3]
-                        total_size_dict['total_size_small'] = total_sizes[7]
+                        total_size_dict_rule['total_number_big'] = total_sizes[1]
+                        total_size_dict['total_number_big'] = total_sizes[5]
+                        total_size_dict_rule['total_number_small'] = total_sizes[3]
+                        total_size_dict['total_number_small'] = total_sizes[7]
                     except:
-                        total_size_dict_rule['total_size_big'] = ""
-                        total_size_dict['total_size_big'] = ""
-                        total_size_dict_rule['total_size_small'] = ""
-                        total_size_dict['total_size_small'] = ""
+                        total_size_dict_rule['total_number_big'] = ""
+                        total_size_dict['total_number_big'] = ""
+                        total_size_dict_rule['total_number_small'] = ""
+                        total_size_dict['total_number_small'] = ""
 # 总得分: 大/小 前5局-----------------------------------------------------------------------------------------------------
                     try:
                         total_sizes = result['o']["ouf5in"]["v"]
-                        total_size_dict_rule['five_total_size_big'] = total_sizes[1]
-                        total_size_dict['five_total_size_big'] = total_sizes[5]
-                        total_size_dict_rule['five_total_size_small'] = total_sizes[3]
-                        total_size_dict['five_total_size_small'] = total_sizes[7]
+                        total_size_dict_rule['five_total_number_big'] = total_sizes[1]
+                        total_size_dict['five_total_number_big'] = total_sizes[5]
+                        total_size_dict_rule['five_total_number_small'] = total_sizes[3]
+                        total_size_dict['five_total_number_small'] = total_sizes[7]
                     except:
-                        total_size_dict_rule['five_total_size_big'] = ""
-                        total_size_dict['five_total_size_big'] = ""
-                        total_size_dict_rule['five_total_size_small'] = ""
-                        total_size_dict['five_total_size_small'] = ""
+                        total_size_dict_rule['five_total_number_big'] = ""
+                        total_size_dict['five_total_number_big'] = ""
+                        total_size_dict_rule['five_total_number_small'] = ""
+                        total_size_dict['five_total_number_small'] = ""
 
 # ------------------------------------------------------总得分:单/双-----------------------------------------------------
                     odd_evens_dict = {}
@@ -187,8 +187,8 @@ class BqrangqiuSpider(scrapy.Spider):
 
                     except:
                         odd_evens_dict['two_sides_single'] = ""
-                        odd_evens_dict['two_sides_single'] = ""
-                        odd_evens_dict_rule['two_sides_double'] = ""
+                        odd_evens_dict['two_sides_double'] = ""
+                        odd_evens_dict_rule['two_sides_single'] = ""
                         odd_evens_dict_rule['two_sides_double'] = ""
 
                     # 联赛id

+ 50 - 50
hg3535/spiders/roll_lanqiu.py

@@ -154,9 +154,9 @@ class LanqiuSpider(scrapy.Spider):
                 one_concede_guest_rule = ""
                 one_concede_home = ""
                 one_concede_home_rule = ""
-                concedes_dict['one_concede_home_rule'] = one_concede_home_rule
+                concedes_dict_rule['one_concede_home'] = one_concede_home_rule
                 concedes_dict['one_concede_home'] = one_concede_home
-                concedes_dict['one_concede_guest_rule'] = one_concede_guest_rule
+                concedes_dict_rule['one_concede_guest'] = one_concede_guest_rule
                 concedes_dict['one_concede_guest'] = one_concede_guest
             # 第二节让球
             try:
@@ -218,104 +218,104 @@ class LanqiuSpider(scrapy.Spider):
             try:
                 total_sizes = result['o']["ou"]["v"]
                 total_sizes_big_rule,total_sizes_big,total_sizes_small_rule,total_sizes_small = rangqiu_daxiao(inner=total_sizes)
-                total_sizes_dict_rule["total_size_big"] = total_sizes_big_rule
-                total_sizes_dict["total_size_big"] = total_sizes_big
-                total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
-                total_sizes_dict["total_size_small"] = total_sizes_small
+                total_sizes_dict_rule["total_sizes_big"] = total_sizes_big_rule
+                total_sizes_dict["total_sizes_big"] = total_sizes_big
+                total_sizes_dict_rule["total_sizes_small"] = total_sizes_small_rule
+                total_sizes_dict["total_sizes_small"] = total_sizes_small
             except:
                 total_sizes_big_rule = ""
                 total_sizes_big = ""
                 total_sizes_small_rule = ""
                 total_sizes_small = ""
-                total_sizes_dict_rule["total_size_big"] = total_sizes_big_rule
-                total_sizes_dict["total_size_big"] = total_sizes_big
-                total_sizes_dict_rule["total_size_small"] = total_sizes_small_rule
-                total_sizes_dict["total_size_small"] = total_sizes_small
+                total_sizes_dict_rule["total_sizes_big"] = total_sizes_big_rule
+                total_sizes_dict["total_sizes_big"] = total_sizes_big
+                total_sizes_dict_rule["total_sizes_small"] = total_sizes_small_rule
+                total_sizes_dict["total_sizes_small"] = total_sizes_small
             # 上半场总分大小
             try:
                 half_total_sizes = result['o']["ou1st"]["v"]
                 half_total_sizes_big_rule,half_total_sizes_big,half_total_sizes_small_rule,half_total_sizes_small = rangqiu_daxiao(inner=half_total_sizes)
-                total_sizes_dict_rule["half_total_size_big"] = half_total_sizes_big_rule
-                total_sizes_dict["half_total_size_big"] = half_total_sizes_big
-                total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
-                total_sizes_dict["half_total_size_small"] = half_total_sizes_small
+                total_sizes_dict_rule["half_total_sizes_big"] = half_total_sizes_big_rule
+                total_sizes_dict["half_total_sizes_big"] = half_total_sizes_big
+                total_sizes_dict_rule["half_total_sizes_small"] = half_total_sizes_small_rule
+                total_sizes_dict["half_total_sizes_small"] = half_total_sizes_small
             except:
                 half_total_sizes_big_rule = ""
                 half_total_sizes_big = ""
                 half_total_sizes_small_rule = ""
                 half_total_sizes_small = ""
-                total_sizes_dict_rule["half_total_size_big"] = half_total_sizes_big_rule
-                total_sizes_dict["half_total_size_big"] = half_total_sizes_big
-                total_sizes_dict_rule["half_total_size_small"] = half_total_sizes_small_rule
-                total_sizes_dict["half_total_size_small"] = half_total_sizes_small
+                total_sizes_dict_rule["half_total_sizes_big"] = half_total_sizes_big_rule
+                total_sizes_dict["half_total_sizes_big"] = half_total_sizes_big
+                total_sizes_dict_rule["half_total_sizes_small"] = half_total_sizes_small_rule
+                total_sizes_dict["half_total_sizes_small"] = half_total_sizes_small
             # 第一节总分大小
             try:
                 one_total_sizes = result['o']["ou1st"]["v"]
                 one_total_sizes_big_rule,one_total_sizes_big,one_total_sizes_small_rule,one_total_sizes_small = rangqiu_daxiao(inner=one_total_sizes)
-                total_sizes_dict_rule["one_total_size_big"] = one_total_sizes_big_rule
-                total_sizes_dict["one_total_size_big"] = one_total_sizes_big
-                total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
-                total_sizes_dict["one_total_size_small"] = one_total_sizes_small
+                total_sizes_dict_rule["one_total_sizes_big"] = one_total_sizes_big_rule
+                total_sizes_dict["one_total_sizes_big"] = one_total_sizes_big
+                total_sizes_dict_rule["one_total_sizes_small"] = one_total_sizes_small_rule
+                total_sizes_dict["one_total_sizes_small"] = one_total_sizes_small
             except:
                 one_total_sizes_big_rule = ""
                 one_total_sizes_big = ""
                 one_total_sizes_small_rule = ""
                 one_total_sizes_small = ""
-                total_sizes_dict_rule["one_total_size_big"] = one_total_sizes_big_rule
-                total_sizes_dict["one_total_size_big"] = one_total_sizes_big
-                total_sizes_dict_rule["one_total_size_small"] = one_total_sizes_small_rule
-                total_sizes_dict["one_total_size_small"] = one_total_sizes_small
+                total_sizes_dict_rule["one_total_sizes_big"] = one_total_sizes_big_rule
+                total_sizes_dict["one_total_sizes_big"] = one_total_sizes_big
+                total_sizes_dict_rule["one_total_sizes_small"] = one_total_sizes_small_rule
+                total_sizes_dict["one_total_sizes_small"] = one_total_sizes_small
             # 第二节场总分大小
             try:
                 two_total_sizes = result['o']["ou2st"]["v"]
                 two_total_sizes_big_rule,two_total_sizes_big,two_total_sizes_small_rule,two_total_sizes_small = rangqiu_daxiao(inner=two_total_sizes)
-                total_sizes_dict_rule["two_total_size_big"] = two_total_sizes_big_rule
-                total_sizes_dict["two_total_size_big"] = two_total_sizes_big
-                total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
-                total_sizes_dict["two_total_size_small"] = two_total_sizes_small
+                total_sizes_dict_rule["two_total_sizes_big"] = two_total_sizes_big_rule
+                total_sizes_dict["two_total_sizes_big"] = two_total_sizes_big
+                total_sizes_dict_rule["two_total_sizes_small"] = two_total_sizes_small_rule
+                total_sizes_dict["two_total_sizes_small"] = two_total_sizes_small
             except:
                 two_total_sizes_big_rule = ""
                 two_total_sizes_big = ""
                 two_total_sizes_small_rule = ""
                 two_total_sizes_small = ""
-                total_sizes_dict_rule["two_total_size_big"] = two_total_sizes_big_rule
-                total_sizes_dict["two_total_size_big"] = two_total_sizes_big
-                total_sizes_dict_rule["two_total_size_small"] = two_total_sizes_small_rule
-                total_sizes_dict["two_total_size_small"] = two_total_sizes_small
+                total_sizes_dict_rule["two_total_sizes_big"] = two_total_sizes_big_rule
+                total_sizes_dict["two_total_sizes_big"] = two_total_sizes_big
+                total_sizes_dict_rule["two_total_sizes_small"] = two_total_sizes_small_rule
+                total_sizes_dict["two_total_sizes_small"] = two_total_sizes_small
             # 第三节总分大小
             try:
                 three_total_sizes = result['o']["ou3st"]["v"]
                 three_total_sizes_big_rule,three_total_sizes_big,three_total_sizes_small_rule,three_total_sizes_small = rangqiu_daxiao(inner=three_total_sizes)
-                total_sizes_dict_rule["three_total_size_big"] = three_total_sizes_big_rule
-                total_sizes_dict["three_total_size_big"] = three_total_sizes_big
-                total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
-                total_sizes_dict["three_total_size_small"] = three_total_sizes_small
+                total_sizes_dict_rule["three_total_sizes_big"] = three_total_sizes_big_rule
+                total_sizes_dict["three_total_sizes_big"] = three_total_sizes_big
+                total_sizes_dict_rule["three_total_sizes_small"] = three_total_sizes_small_rule
+                total_sizes_dict["three_total_sizes_small"] = three_total_sizes_small
             except:
                 three_total_sizes_big_rule = ""
                 three_total_sizes_big = ""
                 three_total_sizes_small_rule = ""
                 three_total_sizes_small = ""
-                total_sizes_dict_rule["three_total_size_big"] = three_total_sizes_big_rule
-                total_sizes_dict["three_total_size_big"] = three_total_sizes_big
-                total_sizes_dict_rule["three_total_size_small"] = three_total_sizes_small_rule
-                total_sizes_dict["three_total_size_small"] = three_total_sizes_small
+                total_sizes_dict_rule["three_total_sizes_big"] = three_total_sizes_big_rule
+                total_sizes_dict["three_total_sizes_big"] = three_total_sizes_big
+                total_sizes_dict_rule["three_total_sizes_small"] = three_total_sizes_small_rule
+                total_sizes_dict["three_total_sizes_small"] = three_total_sizes_small
             # 第四节总分大小
             try:
                 four_total_sizes = result['o']["ou4st"]["v"]
                 four_total_sizes_big_rule,four_total_sizes_big,four_total_sizes_small_rule,four_total_sizes_small = rangqiu_daxiao(inner=four_total_sizes)
-                total_sizes_dict_rule["four_total_size_big"] = four_total_sizes_big_rule
-                total_sizes_dict["four_total_size_big"] = four_total_sizes_big
-                total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
-                total_sizes_dict["four_total_size_small"] = four_total_sizes_small
+                total_sizes_dict_rule["four_total_sizes_big"] = four_total_sizes_big_rule
+                total_sizes_dict["four_total_sizes_big"] = four_total_sizes_big
+                total_sizes_dict_rule["four_total_sizes_small"] = four_total_sizes_small_rule
+                total_sizes_dict["four_total_sizes_small"] = four_total_sizes_small
             except:
                 four_total_sizes_big_rule = ""
                 four_total_sizes_big = ""
                 four_total_sizes_small_rule = ""
                 four_total_sizes_small = ""
-                total_sizes_dict_rule["four_total_size_big"] = four_total_sizes_big_rule
-                total_sizes_dict["four_total_size_big"] = four_total_sizes_big
-                total_sizes_dict_rule["four_total_size_small"] = four_total_sizes_small_rule
-                total_sizes_dict["four_total_size_small"] = four_total_sizes_small
+                total_sizes_dict_rule["four_total_sizes_big"] = four_total_sizes_big_rule
+                total_sizes_dict["four_total_sizes_big"] = four_total_sizes_big
+                total_sizes_dict_rule["four_total_sizes_small"] = four_total_sizes_small_rule
+                total_sizes_dict["four_total_sizes_small"] = four_total_sizes_small
 
 # ----------------------------------------总分单双分割线------------------------------------------------------------------
             # 全场 总分单双

+ 16 - 16
hg3535/spiders/roll_wangqiu.py

@@ -130,19 +130,19 @@ class WangqiuSpider(scrapy.Spider):
                 # 第一节让球
                 one_concedes = result['o']["ahs1"]["v"]
                 one_concede_home_rule,one_concede_home,one_concede_guest_rule,one_concede_guest= rangqiu_daxiao(inner=one_concedes)
-                concedes_dict_rule['one_concede_home'] = ''.join(one_concede_home_rule)
-                concedes_dict['one_concede_home'] = ''.join(one_concede_home)
-                concedes_dict_rule['one_concede_guest'] = ''.join(one_concede_guest_rule)
-                concedes_dict['one_concede_guest'] = ''.join(one_concede_guest)
+                concedes_dict_rule['one_dishes_home'] = ''.join(one_concede_home_rule)
+                concedes_dict['one_dishes_home'] = ''.join(one_concede_home)
+                concedes_dict_rule['one_dishes_guest'] = ''.join(one_concede_guest_rule)
+                concedes_dict['one_dishes_guest'] = ''.join(one_concede_guest)
             except:
                 one_concede_guest = ""
                 one_concede_guest_rule = ""
                 one_concede_home = ""
                 one_concede_home_rule = ""
-                concedes_dict['one_concede_home_rule'] = one_concede_home_rule
-                concedes_dict['one_concede_home'] = one_concede_home
-                concedes_dict['one_concede_guest_rule'] = one_concede_guest_rule
-                concedes_dict['one_concede_guest'] = one_concede_guest
+                concedes_dict['one_dishes_home_rule'] = one_concede_home_rule
+                concedes_dict['one_dishes_home'] = one_concede_home
+                concedes_dict['one_dishes_guest_rule'] = one_concede_guest_rule
+                concedes_dict['one_dishes_guest'] = one_concede_guest
 
 # ----------------------------------------第二节让球分割线---------------------------------------------------------------------------
 
@@ -151,19 +151,19 @@ class WangqiuSpider(scrapy.Spider):
             try:
                 two_concedes = result['o']["ahs2"]["v"]
                 two_concede_home_rule,two_concede_home,two_concede_guest_rule,two_concede_guest = rangqiu_daxiao(inner=two_concedes)
-                concedes_dict_rule['two_concede_home'] = ''.join(two_concede_home_rule)
-                concedes_dict['two_concede_home'] = ''.join(two_concede_home)
-                concedes_dict_rule['two_concede_guest'] = ''.join(two_concede_guest_rule)
-                concedes_dict['two_concede_guest'] = ''.join(two_concede_guest)
+                concedes_dict_rule['two_dishes_home'] = ''.join(two_concede_home_rule)
+                concedes_dict['two_dishes_home'] = ''.join(two_concede_home)
+                concedes_dict_rule['two_dishes_guest'] = ''.join(two_concede_guest_rule)
+                concedes_dict['two_dishes_guest'] = ''.join(two_concede_guest)
             except:
                 two_concede_guest = ""
                 two_concede_guest_rule = ""
                 two_concede_home = ""
                 two_concede_home_rule = ""
-                concedes_dict_rule['two_concede_home'] = two_concede_home_rule
-                concedes_dict['two_concede_home'] = two_concede_home
-                concedes_dict_rule['two_concede_guest'] = two_concede_guest_rule
-                concedes_dict['two_concede_guest'] = two_concede_guest
+                concedes_dict_rule['two_dishes_home'] = two_concede_home_rule
+                concedes_dict['two_dishes_home'] = two_concede_home
+                concedes_dict_rule['two_dishes_guest'] = two_concede_guest_rule
+                concedes_dict['two_dishes_guest'] = two_concede_guest
 
 
 

+ 40 - 88
hg3535/spiders/roll_zuqiu.py

@@ -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:

+ 4 - 1
hg3535/spiders/zuqiu.py

@@ -105,7 +105,10 @@ class ZuqiuSpider(scrapy.Spider):
                         # 下半场
                         half_way = data['i'][12]
                         # 角球或者其他
-                        corner_ball = data['pci'].get('ctn', "")
+                        try:
+                            corner_ball = data['pci']['ctn']
+                        except:
+                            corner_ball = 0
                         # 日期
                         data_game = data['i'][4]
                         # 开赛时间