aaaaa.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import logging
  2. from twisted.internet import defer, reactor
  3. from ..utils.helper import Helper
  4. from ..settings import LEAGUE_URL, MATCH_URL
  5. import time
  6. class LqSportsPipeline(object):
  7. @defer.inlineCallbacks
  8. <<<<<<< HEAD:hgg070_spider/pipelines/aaaaa.py
  9. def process_item(self,item,spider):
  10. logger=logging.getLogger(__name__)
  11. =======
  12. def process_item(self, item, spider):
  13. print('555555555555555555555555555555555555555555555555555555555555555555555')
  14. logger = logging.getLogger(__name__)
  15. >>>>>>> d24c6bfe93390b44800468998733ecf116d4bdf0:hgg070_spider/pipelines/lq_sports.py
  16. logger.info("进入管道")
  17. out = defer.Deferred()
  18. reactor.callInThread(self._do_calculation, item, out)
  19. yield out
  20. def _do_calculation(self, item, out):
  21. # 先保存联赛
  22. league_name = item['league']
  23. uuid = Helper.genearte_uuid(league_name)
  24. # 是否串场
  25. if item['isP'] == 'P':
  26. ris_stringscene = 1
  27. else:
  28. ris_stringscene = 0
  29. # 现在时间,时间戳
  30. utime = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
  31. odds_key = ["game_code", "title", "match_id", "lg_id", "data", "source", "odds_only", "tag", "uuid",
  32. "is_stringscene", "utime", "pt", 'match_identity']
  33. odds_value = ["lq", "odds", item['match_id'], item['league_id'], item["content"], "hgg070", [],
  34. item['more_count'], uuid,
  35. ris_stringscene, utime, item['isP'], item["match_identity"]]
  36. # 赛事
  37. childer = dict(zip(odds_key, odds_value))
  38. res = Helper.async_post(LEAGUE_URL, childer)
  39. if res:
  40. if res.get('status') == 1:
  41. logging.warning("联赛提交成功,{}".format(res))
  42. else:
  43. logging.warning("联赛提交失败,{}".format(res))
  44. else:
  45. logging.warning("联赛提交失败,{}".format(res))