Your Name 6 vuotta sitten
vanhempi
commit
f3fe41bbf2
4 muutettua tiedostoa jossa 19 lisäystä ja 16 poistoa
  1. 2 2
      hg3535/main.py
  2. 13 12
      hg3535/pipeline/roll_lanqiu.py
  3. 2 1
      hg3535/settings.py
  4. 2 1
      hg3535/spiders/roll_lanqiu.py

+ 2 - 2
hg3535/main.py

@@ -11,8 +11,8 @@ sys.path.append(os.path.dirname(os.path.abspath(__file__)))
 # execute(["scrapy", "crawl", "wangqiu"])
 # execute(["scrapy", "crawl", "wqbodan"])
 # execute(["scrapy", "crawl", "bangqiu"])
-execute(["scrapy", "crawl", "roll_zuqiu"]) # 滚球足球 回来要解开这个注释 其他全部解封
-# execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
+# execute(["scrapy", "crawl", "roll_zuqiu"]) # 滚球足球 回来要解开这个注释 其他全部解封
+execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
 # execute(["scrapy", "crawl", "roll_wangqiu"]) #滚球网球
 # execute(["scrapy", "crawl", "roll_bangqiu"])  # 滚球棒球
 # execute(["scrapy", "crawl", "ball_status"]) #滚球id本地存

+ 13 - 12
hg3535/pipeline/roll_lanqiu.py

@@ -16,15 +16,15 @@ class Roll_Lanqiupipeline(object):
         self.mongo = pymongo.MongoClient(host=M_HOST, username=M_USER, password=M_PASSWORD, port=M_POST)
         self.db = self.mongo[M_DB]
 
-    @defer.inlineCallbacks
-    def process_item(self, item, spider):
-        out = defer.Deferred()
-        reactor.callInThread(self._do_calculation, item, out)
-        yield out
-        defer.returnValue(item)
-
+    # @defer.inlineCallbacks
     # def process_item(self, item, spider):
-    def _do_calculation(self, item, out):
+    #     out = defer.Deferred()
+    #     reactor.callInThread(self._do_calculation, item, out)
+    #     yield out
+    #     defer.returnValue(item)
+
+    def process_item(self, item, spider):
+    # def _do_calculation(self, item, out):
         # 使用twisted将mysql插入变成异步执行
         logger = logging.getLogger(__name__)
         # 联赛id
@@ -186,11 +186,11 @@ class Roll_Lanqiupipeline(object):
                     odd_evens_data = dict(zip(odd_evens_key, odd_evens_value))
                     data_list.append(odd_evens_data)
 
-        lastnumber_dict = {'0或5': 'lnh0', '1或6': 'lnh1', '2或7': 'lnh2', '3或8': 'lnh3', '4或9': 'lnh4'}
+        lasthome_dict = {'0或5': 'lnh0', '1或6': 'lnh1', '2或7': 'lnh2', '3或8': 'lnh3', '4或9': 'lnh4'}
         last_home = last_numbers_dict['last_home']
         if last_home:
             for key, value in last_home.items():
-                odds_code =lastnumber_dict[key]
+                odds_code =lasthome_dict[key]
                 hash_str = "LN" + odds_code + '0' + str(key) + str(
                     value) + "hg3535" + str(match_id)
                 sole_str = "LN" + str(key) + '0' + str(match_id) + "hg3535"
@@ -204,9 +204,10 @@ class Roll_Lanqiupipeline(object):
                 data_list.append(last_home_data)
 
         last_guest = last_numbers_dict['last_guest']
+        lastguest_dict = {'0或5': 'lng0', '1或6': 'lng1', '2或7': 'lng2', '3或8': 'lng3', '4或9': 'lng4'}
         if last_guest:
             for key, value in last_guest.items():
-                odds_code = lastnumber_dict[key]
+                odds_code = lastguest_dict[key]
                 # condition = lastnumber_dict[key]
                 hash_str = "LN" + odds_code + '0' + str(key) + str(value) + "hg3535" + str(match_id)
                 sole_str = "LN" + str(key) + '0' + str(match_id) + "hg3535"
@@ -314,4 +315,4 @@ class Roll_Lanqiupipeline(object):
         # else:
         #     logger.warning('{},赛事结果状态接口异常提交失败, {}'.format('lq', res))
         #     logger.warning(status_dict)
-        reactor.callFromThread(out.callback, item)
+        # reactor.callFromThread(out.callback, item)

+ 2 - 1
hg3535/settings.py

@@ -147,7 +147,8 @@ M_PASSWORD = 'kaiyou'
 
 LEAGUE_URL = 'http://stadmin.bocai108.com:19093/setLeague'
 MATCH_URL = 'http://stadmin.bocai108.com/setMatch'
-ODDS_URL = 'http://stadmin.bocai108.com:19093/setOdds'
+# ODDS_URL = 'http://stadmin.bocai108.com:19093/setOdds'
+ODDS_URL = 'http://stadmin.bocai108.com/setOdds'
 TOKEN_URL = "http://stadmin.bocai108.com/getToken"
 MATCH_RESULT = "http://stadmin.bocai108.com:19093/setMatchResult"
 MATCH_STATUS = "http://stadmin.bocai108.com:19093/upMatch"

+ 2 - 1
hg3535/spiders/roll_lanqiu.py

@@ -66,7 +66,8 @@ class LanqiuSpider(scrapy.Spider):
                     for es in egs:
                         es = es['es']
                         for e in es:
-                            match_id = e['i'][16]
+                            # match_id = e['i'][16]
+                            match_id = 3460582
                             self.rls.sadd('hg3535.gunqiu.ids', match_id)
                             up_time = str(time.time()) + '&' + 'lq'
                             self.rls.hset('hg3535.ball.ids', match_id, up_time)