瀏覽代碼

'修改球类url'

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

+ 2 - 2
new_hg3535s/hg3535/main.py

@@ -5,9 +5,9 @@ from scrapy.cmdline import execute
 # print(os.path.dirname(os.path.abspath(__file__)))
 sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 # execute(["scrapy", "crawl", "liansai"])
-# execute(["scrapy", "crawl", "zuqiu"])
+execute(["scrapy", "crawl", "zuqiu"])
 # execute(["scrapy", "crawl", "lanqiu"])
-execute(["scrapy", "crawl", "guanjun"])
+# execute(["scrapy", "crawl", "guanjun"])
 # execute(["scrapy", "crawl", "wangqiu"])
 # execute(["scrapy", "crawl", "wqbodan"])
 # execute(["scrapy", "crawl", "bangqiu"])

+ 9 - 23
new_hg3535s/hg3535/pipelines.py

@@ -1,23 +1,10 @@
-# -*- coding: utf-8 -*-
-
-# Define your item pipelines here
-#
-# Don't forget to add your pipeline to the ITEM_PIPELINES setting
-# See: https://doc.scrapy.org/en/latest/topics/item-pipeline.html
 import datetime
 import time
 import hashlib
-
-
 import redis
 from twisted.enterprise import adbapi
 import psycopg2.extras
 
-
-# conn = psycopg2.connect(host='localhost', port=5433, user='postgres', password='123456', database='postgres')
-
-# conn = psycopg2.connect(host='localhost', port=10432, user='kaiyou', password='123456', database='kaiyou')
-
 # class MySnow:
 #     def __init__(self,dataID):
 #         self.start = int(time.mktime(time.strptime('2018-01-01 00:00:00', "%Y-%m-%d %H:%M:%S")))
@@ -738,7 +725,7 @@ class Zuqiupipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1002,7 +989,7 @@ class Lanqiupipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1144,7 +1131,7 @@ class Wangqiupipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1210,7 +1197,7 @@ class Wangqiupipeline(object):
         # 总局数单双
         odd_evens_dict = item['odd_evens_dict']
         odd_evens_dict_rule = item['odd_evens_dict_rule']
-
+        #
         # 让球
         concede = {'league_id': league_id, 'game_id': game_id, 'utime': utime, 'p_id': 1, 'p_code': "wq_concede",
                    'source': "hg3535", 'expire_time': expire_time, 'sort': 0, 'pt': pt}
@@ -1309,7 +1296,7 @@ class Wqbodanpipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1435,7 +1422,7 @@ class Bangqiupipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1596,7 +1583,7 @@ class Guanjunpipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1709,7 +1696,7 @@ class Liansaipipeline(object):
         dbpool = adbapi.ConnectionPool("psycopg2", **dbparms)
         conn = psycopg2.connect(host=settings["POST_HOST"], port=settings['POST_PORT'], user=settings["POST_USER"], password=settings["POST_PASSWORD"], database=settings["POST_DATABASE"])
         cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
-        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"])
+        pool = redis.ConnectionPool(host=settings["R_HOST"], port=settings["R_POST"], password=settings["R_PASSWORD"])
         redis_db = redis.StrictRedis(connection_pool=pool)
         return cls(dbpool, conn, cursor, redis_db)
 
@@ -1798,5 +1785,4 @@ class Liansaipipeline(object):
     def close_spider(self, spider):
         self.conn.close()
         self.dbpool.close()
-        # self.redis_db.disconnect()
-
+        # self.redis_db.disconnect()

+ 11 - 10
new_hg3535s/hg3535/settings.py

@@ -110,17 +110,18 @@ ITEM_PIPELINES = {
 #HTTPCACHE_IGNORE_HTTP_CODES = []
 #HTTPCACHE_STORAGE = 'scrapy.extensions.httpcache.FilesystemCacheStorage'
 
-# POST_HOST = 'localhost'
-# POST_DATABASE = 'postgres'
-# POST_USER = 'postgres'
-# POST_PORT = '5433'
-# POST_PASSWORD = '123456'
+POST_HOST = 'localhost'
+POST_DATABASE = 'postgres'
+POST_USER = 'postgres'
+POST_PORT = '5433'
+POST_PASSWORD = '123456'
 
 R_HOST = 'localhost'
 R_POST = '6379'
+R_PASSWORD = '123456'
 
-POST_HOST = '192.168.2.200'
-POST_DATABASE = 'kaiyou'
-POST_USER = 'kaiyou'
-POST_PORT = '10432'
-POST_PASSWORD = '123456'
+# POST_HOST = '192.168.2.200'
+# POST_DATABASE = 'kaiyou'
+# POST_USER = 'kaiyou'
+# POST_PORT = '10432'
+# POST_PASSWORD = '123456'

+ 4 - 4
new_hg3535s/hg3535/spiders/bangqiu.py

@@ -18,7 +18,7 @@ class BqrangqiuSpider(scrapy.Spider):
     }
     def start_requests(self):
         for y in range(1, 4):
-            url = 'http://hg3535z.com/odds2/d/getodds?sid=4&pt=' + str(y) + '&ubt=am&pn=0&sb=2&dc=null&pid=0'
+            url = 'https://hg3535z.com/odds2/d/getodds?sid=4&pt=' + str(y) + '&ubt=am&pn=0&sb=2&dc=null&pid=0'
             yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y, 'dont_redirect': True})
 
     def parse(self, response):
@@ -37,13 +37,13 @@ class BqrangqiuSpider(scrapy.Spider):
                     for new_result in new_results:
                         game_id = str(new_result['i'][16])
                         if pt == 1:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 2:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 3:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
 
     def parse_each(self, response):

+ 1 - 1
new_hg3535s/hg3535/spiders/guanjun.py

@@ -21,7 +21,7 @@ class LqguanjunSpider(scrapy.Spider):
         for z in range(1, 5):
             for y in range(1, 4):
                 for x in range(0, 4):
-                    url = 'http://hg3535z.com/odds2/d/getodds?sid=' + str(z) + '&pt=' + str(y) + '&ubt=or&pn=' + str(
+                    url = 'https://hg3535z.com/odds2/d/getodds?sid=' + str(z) + '&pt=' + str(y) + '&ubt=or&pn=' + str(
                         x) + '&sb=2&dc=null&pid=0'
                     yield Request(url=url, callback=self.parse, meta={'pt': y, 'sid': z, 'url': url})
 

+ 4 - 4
new_hg3535s/hg3535/spiders/lanqiu.py

@@ -71,7 +71,7 @@ class LanqiuSpider(scrapy.Spider):
     def start_requests(self):
         # newall_lists = ['am', 'ftht1x2', 'oe', 'tg', 'htft', 'cs', 'fglg', 'or']
         for y in range(1, 4):
-            url = 'http://hg3535z.com/odds2/d/getodds?sid=2&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
+            url = 'https://hg3535z.com/odds2/d/getodds?sid=2&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
             yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y,'dont_redirect': True})
 
     def parse(self, response):
@@ -91,14 +91,14 @@ class LanqiuSpider(scrapy.Spider):
                     for new_result in new_results:
                         game_id = str(new_result['i'][16])
                         if pt == 1:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 2:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             # http://hg3535z.com/odds2/d/getamodds?eid=3136803&iip=false&ubt=am&isp=false
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 3:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
     def parse_each(self, response):
         new_datas = json.loads(response.text).get('eg', "")

+ 1 - 1
new_hg3535s/hg3535/spiders/liansai.py

@@ -20,7 +20,7 @@ class LanqiulsSpider(scrapy.Spider):
     def start_requests(self):
         for y in range(1, 5):
             for i in range(1, 5):
-                url = 'http://hg3535z.com/odds2/d/getcomps?sid='+str(y)+'&pt=' + str(i) + '&ubt=am&dc=null&pn=0&pid=0'
+                url = 'https://hg3535z.com/odds2/d/getcomps?sid='+str(y)+'&pt=' + str(i) + '&ubt=am&dc=null&pn=0&pid=0'
                 yield scrapy.Request(url=url, callback=self.parse)
 
     def parse(self, response):

+ 4 - 4
new_hg3535s/hg3535/spiders/wangqiu.py

@@ -21,7 +21,7 @@ class LanqiuSpider(scrapy.Spider):
     def start_requests(self):
         # newall_lists = ['am', 'ftht1x2', 'oe', 'tg', 'htft', 'cs', 'fglg', 'or']
         for y in range(1, 4):
-            url = 'http://hg3535z.com/odds2/d/getodds?sid=3&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
+            url = 'https://hg3535z.com/odds2/d/getodds?sid=3&pt='+str(y)+'&ubt=am&pn=0&sb=2&dc=null&pid=0'
             yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y, 'dont_redirect': True})
 
     def parse(self, response):
@@ -40,13 +40,13 @@ class LanqiuSpider(scrapy.Spider):
                     for new_result in new_results:
                         game_id = str(new_result['i'][16])
                         if pt == 1:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 2:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         if pt == 3:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid=" + game_id + "iip=false&ubt=am&isp=true"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
                         # http://hg3535z.com/odds2/d/getamodds?eid=3120299&iip=false&ubt=am&isp=false
     def parse_each(self, response):

+ 4 - 3
new_hg3535s/hg3535/spiders/wgbodan.py → new_hg3535s/hg3535/spiders/wqbodan.py

@@ -1,4 +1,5 @@
 # -*- coding: utf-8 -*-
+import copy
 import json
 
 import scrapy
@@ -9,7 +10,7 @@ from ..items import Wqbodan
 
 
 class WgbodanSpider(scrapy.Spider):
-    name = 'wgbodan'
+    name = 'wqbodan'
     allowed_domains = ['hg3535z.com']
     custom_settings = {
         "ITEM_PIPELINES": {
@@ -18,12 +19,12 @@ class WgbodanSpider(scrapy.Spider):
     }
 
     def start_requests(self):
-        url = 'http://hg3535z.com/odds2/d/getmenu?pid=0'
+        url = 'https://hg3535z.com/odds2/d/getmenu?pid=0'
         yield scrapy.Request(url=url, callback=self.parse_one)
 
     def parse_one(self, response):
         for y in range(1, 4):
-            url = 'http://hg3535z.com/odds2/d/getodds?sid=3&pt=' + str(y) + '&ubt=stcs&pn=0&sb=2&dc=null&pid=0'
+            url = 'https://hg3535z.com/odds2/d/getodds?sid=3&pt=' + str(y) + '&ubt=stcs&pn=0&sb=2&dc=null&pid=0'
             yield Request(url=url, callback=self.parse, meta={'pt': y})
 
     def parse(self, response):

+ 74 - 50
new_hg3535s/hg3535/spiders/zuqiu.py

@@ -20,7 +20,7 @@ class ZuqiuSpider(scrapy.Spider):
 
         for y in range(1, 4):
             for i in range(10):
-                url = 'http://hg3535z.com/odds2/d/getodds?sid=1&pt=' + str(y) + '&ubt=' + 'am' + '&pn=' + str(
+                url = 'https://hg3535z.com/odds2/d/getodds?sid=1&pt=' + str(y) + '&ubt=' + 'am' + '&pn=' + str(
                     i) + '&sb=2&dc=null&pid=0'
                 yield scrapy.Request(url=url, callback=self.parse, meta={'pt': y})
 
@@ -37,14 +37,14 @@ class ZuqiuSpider(scrapy.Spider):
                     new_results = result['es']
                     for new_result in new_results:
                         game_id = str(new_result['i'][16])
-                        if pt == 1:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid="+game_id+"iip=false&ubt=am&isp=false"
+                        if pt is 3:
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=true"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
-                        if pt == 2:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid="+game_id+"iip=false&ubt=am&isp=false"
+                        if pt is 2:
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
-                        if pt == 3:
-                            url = "http://hg3535z.com/odds2/d/getamodds?eid="+game_id+"iip=false&ubt=am&isp=true"
+                        if pt is 1:
+                            url = "https://hg3535z.com/odds2/d/getamodds?eid="+game_id+"&iip=false&ubt=am&isp=false"
                             yield Request(url=url, callback=self.parse_each, meta={'pt': pt})
     def parse_each(self, response):
         # 球队进球数 大小
@@ -99,7 +99,7 @@ class ZuqiuSpider(scrapy.Spider):
                         # 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 == 0:
+                            if i % 2 is 0:
                                 home_rule = str(concede_homes[i])
                                 if home_rule.startswith('+'):
                                     n_home_rule = home_rule.replace('+', '-')
@@ -111,16 +111,19 @@ class ZuqiuSpider(scrapy.Spider):
                                     concede_home_rule.append(home_rule)
                                 # concede_homes[i]
                                 # concede_home
-                        concede_home = [concede_homes[i] for i in range(len(concede_homes)) if i % 2 == 1]
+                        if pt is 3:
+                            concede_home = [float(concede_homes[i]) - 1 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 == 1]
+                        concede_guests = [new_concedes[i] for i in range(len(new_concedes)) if i % 2 is 1]
                         # concede_guest_rule
                         # concede_guest_rule = [concede_guests[i] for i in range(len(concede_guests)) if
                         #                       i % 2 == 0]
                         # concede_guest
                         concede_guest_rule = []
                         for i in range(len(concede_guests)):
-                            if i % 2 == 0:
+                            if i % 2 is 0:
                                 guest_rule = str(concede_guests[i])
                                 if guest_rule.startswith('+'):
                                     n_guest_rule = guest_rule.replace('+', '-')
@@ -130,7 +133,10 @@ class ZuqiuSpider(scrapy.Spider):
                                     concede_guest_rule.append(n_guest_rule)
                                 else:
                                     concede_guest_rule.append(guest_rule)
-                        concede_guest = [concede_guests[i] for i in range(len(concede_guests)) if i % 2 == 1]
+                        if pt is 3:
+                            concede_guest = [float(concede_guests[i]) -1 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:
                         concede_guest = ""
                         concede_guest_rule = ""
@@ -140,9 +146,9 @@ class ZuqiuSpider(scrapy.Spider):
 # 上半场让球half_concede-------------------------------------------------------------------------------------------------
                     try:
                         half_concedes = data['o']['ah1st']['v']
-                        new_half_concedes = [half_concedes[i] for i in range(len(half_concedes)) if i % 2 == 1]
+                        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 == 0]
+                                                  i % 2 is 0]
                         # half_concede_home_rule
                         # half_concede_home_rule = [new_half_concede_homes[i] for i in
                         #                           range(len(new_half_concede_homes)) if i % 2 == 0]
@@ -160,10 +166,11 @@ class ZuqiuSpider(scrapy.Spider):
                                 else:
                                     half_concede_home_rule.append(home_rule)
                         # concede_home
-                        half_concede_home = [new_half_concede_homes[i] for i in
-                                             range(len(new_half_concede_homes)) if i % 2 == 1]
-                        half_concede_guests = [new_half_concedes[i] for i in range(len(new_half_concedes)) if
-                                               i % 2 == 1]
+                        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]
+                        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]
                         # concede_guest_rule
                         # half_concede_guest_rule = [half_concede_guests[i] for i in
                         #                            range(len(half_concede_guests)) if i % 2 == 0]
@@ -180,8 +187,12 @@ class ZuqiuSpider(scrapy.Spider):
                                 else:
                                     half_concede_guest_rule.append(guest_rule)
                         # concede_guest
-                        half_concede_guest = [half_concede_guests[i] for i in range(len(half_concede_guests)) if
-                                              i % 2 == 1]
+                        if pt is 3:
+                            half_concede_guest = [float(half_concede_guests[i]) -1  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
+                                                  i % 2 is 1]
                     except:
                         half_concede_home_rule = ""
                         half_concede_home = ""
@@ -191,18 +202,24 @@ class ZuqiuSpider(scrapy.Spider):
 # 全场大小size 进球大小---------------------------------------------------------------------------------------------------
                     try:
                         sizes = data['o']['ou']['v']
-                        new_sizes = [sizes[i] for i in range(len(sizes)) if i % 2 == 1]
-                        size_homes = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 == 0]
+                        new_sizes = [sizes[i] for i in range(len(sizes)) if i % 2 is 1]
+                        size_homes = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 is 0]
                         # size_home_rule
-                        size_home_rule = [size_homes[i] for i in range(len(size_homes)) if i % 2 == 0]
+                        size_home_rule = [size_homes[i] for i in range(len(size_homes)) if i % 2 is 0]
                         # size_home
-                        size_home = [size_homes[i] for i in range(len(size_homes)) if i % 2 == 1]
+                        if pt is 3:
+                            size_home = [float(size_homes[i]) - 1 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]
 
-                        size_guests = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 == 1]
+                        size_guests = [new_sizes[i] for i in range(len(new_sizes)) if i % 2 is 1]
                         # size_guest_rule
-                        size_guest_rule = [size_guests[i] for i in range(len(size_guests)) if i % 2 == 0]
+                        size_guest_rule = [size_guests[i] for i in range(len(size_guests)) if i % 2 is 0]
                         # csize_guest
-                        size_guest = [size_guests[i] for i in range(len(size_guests)) if i % 2 == 1]
+                        if pt is 3:
+                            size_guest = [float(size_guests[i]) - 1 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:
                         size_guest = ""
                         size_guest_rule = ""
@@ -212,20 +229,27 @@ class ZuqiuSpider(scrapy.Spider):
 # 上半场大小 进球大小 half_size-------------------------------------------------------------------------------------------
                     try:
                         half_sizes = data['o']['ou1st']['v']
-                        new_half_sizes = [half_sizes[i] for i in range(len(half_sizes)) if i % 2 == 1]
-                        half_size_homes = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 == 0]
+                        new_half_sizes = [half_sizes[i] for i in range(len(half_sizes)) if i % 2 is 1]
+                        half_size_homes = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 is 0]
                         # size_home_rule
                         half_size_home_rule = [half_size_homes[i] for i in range(len(half_size_homes)) if
-                                               i % 2 == 0]
+                                               i % 2 is 0]
                         # half_size_home 主队
-                        half_size_home = [half_size_homes[i] for i in range(len(half_size_homes)) if i % 2 == 1]
-                        half_size_guests = [new_half_sizes[i] for i in range(len(new_half_sizes)) if i % 2 == 1]
+                        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]
+                        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]
                         # half_size_guest_rule 客队
                         half_size_guest_rule = [half_size_guests[i] for i in range(len(half_size_guests)) if
-                                                i % 2 == 0]
+                                                i % 2 is 0]
                         # half_size_guest
-                        half_size_guest = [half_size_guests[i] for i in range(len(half_size_guests)) if
-                                           i % 2 == 1]
+                        if pt is 3:
+                            half_size_guest = [float(half_size_guests[i]) - 1 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
+                                               i % 2 is 1]
                     except:
                         half_size_guest = ""
                         half_size_guest_rule = ""
@@ -236,7 +260,7 @@ class ZuqiuSpider(scrapy.Spider):
                     total_goal = {}
                     try:
                         total_goals = data['o']['tg']['v']
-                        new_total_goals = [total_goals[i] for i in range(len(total_goals)) if i % 2 == 1]
+                        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
@@ -250,7 +274,7 @@ class ZuqiuSpider(scrapy.Spider):
 # 总进球上半场 half_total_goal-------------------------------------------------------------------------------------------
                     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 == 1]
+                        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
@@ -269,7 +293,7 @@ class ZuqiuSpider(scrapy.Spider):
                     # 早盘 半场/全场
                     try:
                         half_fulls = data['o']['hf']['v']
-                        new_half_fulls = [half_fulls[i] for i in range(len(half_fulls)) if i % 2 == 1]
+                        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
                     except:
@@ -280,7 +304,7 @@ class ZuqiuSpider(scrapy.Spider):
                     first_last_ball = {}
                     try:
                         first_balls = data['o']['ttslast']['v']
-                        first_ball = [first_balls[i] for i in range(len(first_balls)) if i % 2 == 1]
+                        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
                     except:
@@ -290,7 +314,7 @@ 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 == 1]
+                        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
@@ -301,7 +325,7 @@ class ZuqiuSpider(scrapy.Spider):
 
                     try:
                         capots = data['o']['1x2']['v']
-                        new_capots = [capots[i] for i in range(len(capots)) if i % 2 == 1]
+                        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
@@ -313,7 +337,7 @@ class ZuqiuSpider(scrapy.Spider):
                     # 上半场独赢capot
                     try:
                         half_capots = data['o']['1x21st']['v']
-                        new_half_capots = [half_capots[i] for i in range(len(half_capots)) if i % 2 == 1]
+                        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
@@ -325,7 +349,7 @@ class ZuqiuSpider(scrapy.Spider):
 # 全场入球:单/双 odd_even------------------------------------------------------------------------------------------------
                     try:
                         odd_evens = data['o']['oe']['v']
-                        new_odd_evens = [odd_evens[i] for i in range(len(odd_evens)) if i % 2 == 1]
+                        new_odd_evens = [odd_evens[i] for i in range(len(odd_evens)) if i % 2 is 1]
                         odd_even_odd = new_odd_evens[0]
                         odd_even_even = new_odd_evens[1]
                     except:
@@ -334,7 +358,7 @@ class ZuqiuSpider(scrapy.Spider):
                     # 半场入球:单/双 half_odd_even
                     try:
                         half_odd_evens = data['o']['oe1st']['v']
-                        new_half_odd_evens = [half_odd_evens[i] for i in range(len(half_odd_evens)) if i % 2 == 1]
+                        new_half_odd_evens = [half_odd_evens[i] for i in range(len(half_odd_evens)) if i % 2 is 1]
                         half_odd_even_odd = new_half_odd_evens[0]
                         half_odd_even_even = new_half_odd_evens[1]
                     except:
@@ -355,14 +379,14 @@ class ZuqiuSpider(scrapy.Spider):
                                     "bodanguest_four_three"]
                         three_list = ["bodandogfall_zero_zero", "bodandogfall_one_one", "bodandogfall_two_two",
                                       "bodandogfall_three_three", "bodandogfall_four_four"]
-                        new_bodans = [bodans[i] for i in range(len(bodans)) if i % 2 == 1]
+                        new_bodans = [bodans[i] for i in range(len(bodans)) if i % 2 is 1]
                         new_bodan = new_bodans[0:20]
                         # 主队bodan_home
-                        bodan_home = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 == 0]
+                        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_guest
-                        bodan_guest = [new_bodan[i] for i in range(len(new_bodan)) if i % 2 == 1]
+                        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_dogfall = new_bodans[-7:-2]
@@ -375,7 +399,7 @@ class ZuqiuSpider(scrapy.Spider):
 
                     try:
                         half_bodans = data['o']['cs1st']['v']
-                        new_half_bodans = [half_bodans[i] for i in range(len(half_bodans)) if i % 2 == 1]
+                        new_half_bodans = [half_bodans[i] for i in range(len(half_bodans)) if i % 2 is 1]
                         new_one = ["halfbodanhome_one_zero", "halfbodanhome_two_zero", "halfbodanhome_two_one",
                                    "halfbodanhome_three_zero", "halfbodanhome_three_one", "halfbodanhome_three_two"]
                         new_two = ["halfbodanguest_one_zero", "halfbodanguest_two_zero", "halfbodanguest_two_one",
@@ -384,12 +408,12 @@ class ZuqiuSpider(scrapy.Spider):
                                      "halfbodandogfall_two_two",
                                      "halfbodandogfall_three_three"]
                         halfbodan = new_half_bodans[0:12]
-                        half_bodan_home = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 == 0]
+                        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
                         # 队2
-                        half_bodan_guest = [halfbodan[i] for i in range(len(halfbodan)) if i % 2 == 1]
+                        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
                         # 和/平