5 Revize 07578778fc ... aee065a0cc

Autor SHA1 Zpráva Datum
  Your Name aee065a0cc 新增足球滚球爬虫 před 6 roky
  Your Name 5153a45b33 新增足球滚球爬虫 před 6 roky
  Your Name 8652829b65 新增足球滚球爬虫 před 6 roky
  Your Name cb4fec1ad8 Merge remote-tracking branch 'origin/master' před 6 roky
  Your Name 0c0ef5a614 新增足球滚球爬虫 před 6 roky

+ 1 - 4
hgg070_spider/main.py

@@ -5,17 +5,14 @@ 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", "zuqiu"])
-<<<<<<< HEAD
 execute(["scrapy", "crawl", "lanqiu"])
-=======
 # execute(["scrapy", "crawl", "lanqiu"])
->>>>>>> d24c6bfe93390b44800468998733ecf116d4bdf0
 # execute(["scrapy", "crawl", "lq_sports"])
 # execute(["scrapy", "crawl", "guanjun"])
 # execute(["scrapy", "crawl", "wangqiu"])
 # execute(["scrapy", "crawl", "wqbodan"])
 # execute(["scrapy", "crawl", "bangqiu"])
-execute(["scrapy", "crawl", "roll_zuqiu"]) # 滚球足球 回来要解开这个注释 其他全部解封
+# execute(["scrapy", "crawl", "roll_zuqiu"]) # 滚球足球 回来要解开这个注释 其他全部解封
 # execute(["scrapy", "crawl", "roll_lanqiu"]) #滚球篮球
 # execute(["scrapy", "crawl", "roll_wangqiu"]) #滚球网球
 # execute(["scrapy", "crawl", "roll_bangqiu"])  # 滚球棒球

+ 1 - 6
hgg070_spider/pipelines/aaaaa.py

@@ -7,14 +7,9 @@ import time
 
 class LqSportsPipeline(object):
     @defer.inlineCallbacks
-<<<<<<< HEAD:hgg070_spider/pipelines/aaaaa.py
+
     def process_item(self,item,spider):
-        logger=logging.getLogger(__name__)
-=======
-    def process_item(self, item, spider):
-        print('555555555555555555555555555555555555555555555555555555555555555555555')
         logger = logging.getLogger(__name__)
->>>>>>> d24c6bfe93390b44800468998733ecf116d4bdf0:hgg070_spider/pipelines/lq_sports.py
         logger.info("进入管道")
         out = defer.Deferred()
         reactor.callInThread(self._do_calculation, item, out)

+ 24 - 11
hgg070_spider/pipelines/roll_zuqiu.py

@@ -57,14 +57,20 @@ class RollPipeline(object):
         json_key = 'zq_rollball'
         match_list = []
         match_identity = Helper.genearte_uuid(team_h + team_c + match_date)
+        ptype_id = match_all.get('ptype_id')
+        is_horn = 0
+        if ptype_id == '146':
+            ptype = match_all['ptype']
+            team_h = team_h.replace(ptype, '').strip()
+            team_c = team_c.replace(ptype, '').strip()
+            is_horn = 1
         if self.db.zq_competition070.find({'match_id': match_id, 'is_rollball': 1}).count() < 1:
             match_dict = {"game_code": "zq", "title": "match", "source": "hgg070"}
             match_kay = ["home_team", "guest_team", "lg_id", "status", "match_id", "match_date", "match_time",
                          "tag", "source", "is_rollball", "is_morningplate", "is_stringscene", "us_time", "uuid",
                          "half_match_id", "is_today", "is_horn", 'match_identity']
             match_value = [team_h, team_c, league_id, 0, match_id, match_date, match_time, tag_number,
-                           "hgg070", 1, 0, 0, us_time, uuid, 0, 0, 0,
-                           match_identity]
+                           "hgg070", 1, 0, 0, us_time, uuid, 0, 0, is_horn, match_identity]
             match_data = dict(zip(match_kay, match_value))
             match_list.append(match_data)
             match_dict['data'] = match_list
@@ -125,23 +131,30 @@ class RollPipeline(object):
                 logging.warning('足球详细赔率接口异常, {}'.format(res))
         else:
             logger.info('足球详细赔率列表为空')
-        data_list = []
+        data_result = []
+        process = {"HT": "半场", "1H": "上半场", "2H": "下半场"}
+        match_process = process[re_time.split('^')[0]]
+        time_game = re_time.split('^')[1][:-1]
+        score_h = match_all.get('score_h')
+        score_c = match_all.get('score_c')
+        # all_goal = score_h + score_c
+        # match_score = '{}:{}'.format(score_h, score_c)
         zq_rball = {"home_team": team_h, "guest_team": team_c,
                     "lg_id": league_id, "home_rate": 0,
-                    "guest_rate": 0, "home_score": score_home,
-                    "guest_score": score_guest, "all_goal": all_goal, "status": 1,
-                    "first_score": "", "last_score": "", "match_score": match_score, "uuid": uuid,
+                    "guest_rate": 0, "home_score": score_h,
+                    "guest_score": score_c, "all_goal": '', "status": 1,
+                    "first_score": "", "last_score": "", "match_score": '', "uuid": uuid,
                     "match_winer": "", "match_time": time_game, 'match_identity': match_identity,
-                    "match_process": half_way, "tag": number,
+                    "match_process": match_process, "tag": tag_number,
                     "match_id": match_id, "p_code": ""}
-        data_list.append(zq_rball)
+        data_result.append(zq_rball)
         r_data_dict = {
             "game_code": "zq",
             "title": "match_result_r",
-            "source": "hg3535",
-            "data": data_list
+            "source": "hgg070",
+            "data": data_result
         }
-        if data_list:
+        if data_result:
             try:
                 res = Helper.async_post(MATCH_RESULT, r_data_dict)
                 if res:

+ 2 - 1
hgg070_spider/settings.py

@@ -103,7 +103,8 @@ MATCH_URL = 'http://admin.5gogo.com/setMatch'  #赛事
 ODDS_URL = 'http://admin.5gogo.com/setOdds'  #赔率
 # ODDS_URL = 'http://stadmin.bocai108.com/setOdds'
 TOKEN_URL = "http://admin.5gogo.com/getToken"  #Token
-MATCH_RESULT = "http://stadmin.bocai108.com:19093/setMatchResult"
+# MATCH_RESULT = "http://stadmin.bocai108.com:19093/setMatchResult"
+MATCH_RESULT = "http://admin.5gogo.com/setMatchResult"
 MATCH_STATUS = "http://stadmin.bocai108.com:19093/upMatch"
 ODDSCH = "http://stadmin.bocai108.com:19093/setOddsCH"
 SAIGUO_RESULT = "http://stadmin.bocai108.com:19093/setResultExpress"

+ 1 - 1
hgg070_spider/spiders/aaaa.py

@@ -4,7 +4,7 @@ import re
 import copy
 from ..items import LanqiuItem
 class LanqiuSpider(scrapy.Spider):
-    name = 'lanqiu'
+    name = 'aaaaa'
     allowed_domains = ['m.hgg070.com/']
     start_urls = ['http://m.hgg070.com//']
     remath=re.compile("篮球")

+ 49 - 46
hgg070_spider/spiders/lanqiu.py

@@ -3,25 +3,27 @@ import scrapy
 from ..items import LanqiuItem
 import copy
 import lxml.etree
-import re,os,json
+import re, os, json
 from ..utils.helper import Helper
 import time
 from ..items import LanqiuItem
 import xmltodict
 
+
 class LqSportsSpider(scrapy.Spider):
-    name = 'lq_sports'
+    name = 'lanqiu'
     allowed_domains = ['m.hgg070.com/']
     start_urls = ['http://m.hgg070.com//']
     remath = re.compile("篮球")
-    custom_settings={
+    custom_settings = {
         "ITEM_PIPELINES": {
             "hgg070_spider.pipelines.lanqiu.LanqiuPipeline": 200,
         },
     }
+
     def start_requests(self):
-        #今日,早盘
-        h_types=[('FT'),('FU')]
+        # 今日,早盘
+        h_types = [('FT'), ('FU')]
         headers = {
             'Accept': '*/*',
             'Accept-Encoding': 'gzip, deflate',
@@ -38,8 +40,8 @@ class LqSportsSpider(scrapy.Spider):
         url = "http://m.hgg070.com/app/member/get_league_list.php"
         for item in h_types:
             showtype = item
-            data={
-                'uid': 'a8b9b2facd6b19ab7023a2b8686207d4ea98c3ab68e455abe8fe49a4861ff68f',
+            data = {
+                'uid': '75384e6a840f9d5801ed61a0ee22b7586b70d4d015b144e1ae83625ec46ca392',
                 'langx': 'zh-cn',
                 'ltype': '3',
                 'gtype': 'BK',
@@ -48,51 +50,52 @@ class LqSportsSpider(scrapy.Spider):
                 'date': '',
                 'isP': ''
             }
-            yield scrapy.FormRequest(url=url,formdata=data,callback=self.parse,headers=headers,
-                                      meta={"data":data}, dont_filter=True)
+            yield scrapy.FormRequest(url=url, formdata=data, callback=self.parse, headers=headers,
+                                     meta={"data": data}, dont_filter=True)
 
     def parse(self, response):
-        #获取id并判断抓取的球型
-        data=response.meta["data"]
-        fromdata=copy.deepcopy(data)
-        league=response.xpath('//league')
-        url="http://m.hgg070.com/app/member/get_game_list.php"
+        # 获取id并判断抓取的球型
+        data = response.meta["data"]
+        fromdata = copy.deepcopy(data)
+        league = response.xpath('//league')
+        url = "http://m.hgg070.com/app/member/get_game_list.php"
         for le in league:
-            name=le.xpath('./league_name/text()').extract_first()
-            if len(self.remath.findall(name))>0:
+            name = le.xpath('./league_name/text()').extract_first()
+            if len(self.remath.findall(name)) > 0:
                 lid = le.xpath('./league_id/text()').extract_first()
                 # 抓取今日
-                if data["showtype"]=="FT":
-                    data['lid'],data['sorttype'],data['date']=lid,'league',''
+                if data["showtype"] == "FT":
+                    data['lid'], data['sorttype'], data['date'] = lid, 'league', ''
                 # 抓取早盘
-                elif data["showtype"]=="FU":
+                elif data["showtype"] == "FU":
                     data['lid'], data['sorttype'], data['date'] = lid, 'league', 'all'
-                yield scrapy.FormRequest(url=url,formdata=data,callback=self.detailball,meta={"data":fromdata},dont_filter=True)
+                yield scrapy.FormRequest(url=url, formdata=data, callback=self.detailball, meta={"data": fromdata},
+                                         dont_filter=True)
 
-    def detailball(self,response):
-        data=response.meta["data"]
-        url="http://m.hgg070.com/app/member/get_game_more.php"
-        #获取联赛id gid
-        game=response.xpath("//game")
+    def detailball(self, response):
+        data = response.meta["data"]
+        url = "http://m.hgg070.com/app/member/get_game_more.php"
+        # 获取联赛id gid
+        game = response.xpath("//game")
         for g in game:
-            gid=g.xpath("./gid/text()").extract_first()
+            gid = g.xpath("./gid/text()").extract_first()
             more_count = g.xpath("./more_count/text()").extract_first()
-            data["gid"]=gid
-            yield scrapy.FormRequest(url=url,formdata=data,callback=self.getItem,meta={"more_count":more_count,"isP":data["isP"]},dont_filter=True)
+            data["gid"] = gid
+            yield scrapy.FormRequest(url=url, formdata=data, callback=self.getItem,
+                                     meta={"more_count": more_count, "isP": data["isP"]}, dont_filter=True)
 
-
-    def getItem(self,response):
+    def getItem(self, response):
         more_count = response.meta["more_count"]
         isP = response.meta["isP"]
-        showtype=response.xpath('//serverresponse/showtype')
-        data= xmltodict.parse(response.text)['serverresponse']['game']
-        game_lists=[i for i in data if i['gopen']=='Y']
+        showtype = response.xpath('//serverresponse/showtype')
+        data = xmltodict.parse(response.text)['serverresponse']['game']
+        game_lists = [i for i in data if i['gopen'] == 'Y']
 
         if game_lists:
             for gl in game_lists:
-                cpath=os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-                with open(cpath+"/conf/hgg070.json",encoding='utf8') as hg:
-                    hgg=json.load(hg)['bk']
+                cpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+                with open(cpath + "/conf/hgg070.json", encoding='utf8') as hg:
+                    hgg = json.load(hg)['bk']
                 datetime = gl['datetime'][:-8] + " " + gl['datetime'][-8:]
                 team_h = gl['team_h']
                 team_c = gl['team_c']
@@ -101,15 +104,15 @@ class LqSportsSpider(scrapy.Spider):
                 match_uid = Helper.genearte_uuid(team_h + team_c + datetime)
                 data = []
                 for hg in hgg:
-                    items=hg['items']
-                    if gl[hg['prodds']]=='Y':
+                    items = hg['items']
+                    if gl[hg['prodds']] == 'Y':
                         for x in items:
                             odds_code = gl[x['rodds']]
                             p_code = gl[hg['prodds']]
-                            odds=gl["ior_OUH"]
-                            #有两个条件,加两条数据
-                            if x['ratio_name']:      #大的
-                                condition_u=gl[x['ratio_name']]
+                            odds = gl["ior_OUH"]
+                            # 有两个条件,加两条数据
+                            if x['ratio_name']:  # 大的
+                                condition_u = gl[x['ratio_name']]
                                 odds_only = hg["plodds"] + x["lodds"] + '0' + str(odds) + "hg3535" + str(match_id)
                                 sole = hg["plodds"] + x["lodds"] + '0' + str(match_id) + "hg3535"
                                 tobj = {"match_id": match_id, "lg_id": league_id, "odds_code": odds_code, "status": 0,
@@ -118,13 +121,13 @@ class LqSportsSpider(scrapy.Spider):
                                         "source": "hgg070", "type": 0, "team": ""}
                                 data.append(tobj)
 
-                            if x['latio']:   #小的
+                            if x['latio']:  # 小的
                                 condition_s = gl[x['latio']]
-                                odds_only =hg["plodds"] + x["lodds"] + '0' + str(odds) + "hg3535" + str(match_id)
+                                odds_only = hg["plodds"] + x["lodds"] + '0' + str(odds) + "hg3535" + str(match_id)
                                 sole = hg["plodds"] + x["lodds"] + '0' + str(match_id) + "hg3535"
                                 tobj = {"match_id": match_id, "lg_id": league_id, "odds_code": odds_code, "status": 0,
                                         "sort": 0, "p_code": p_code,
-                                        "odds": odds,"condition": condition_s, "odds_only": odds_only, "sole": sole,
+                                        "odds": odds, "condition": condition_s, "odds_only": odds_only, "sole": sole,
                                         "source": "hgg070", "type": 0, "team": ""}
                                 data.append(tobj)
 
@@ -134,7 +137,7 @@ class LqSportsSpider(scrapy.Spider):
                                 sole = hg["plodds"] + x["lodds"] + '0' + str(match_id) + "hg3535"
                                 tobj = {"match_id": match_id, "lg_id": league_id, "odds_code": odds_code, "status": 0,
                                         "sort": 0, "p_code": p_code,
-                                        "odds": odds,"condition": condition_s, "odds_only": odds_only, "sole": sole,
+                                        "odds": odds, "condition": condition_s, "odds_only": odds_only, "sole": sole,
                                         "source": "hgg070", "type": 0, "team": ""}
                                 data.append(tobj)
 

+ 3 - 3
hgg070_spider/spiders/roll_zuqiu.py

@@ -35,7 +35,7 @@ class ZuqiuSpider(scrapy.Spider):
     def start_requests(self):
         url = "http://m.hgg070.com/app/member/get_league_list.php"
         from_data = {
-            'uid': '9965a18b03dc6aacf12290bd5b8267fd7e38ec76eadf899b6108e82da5974cdd',
+            'uid': '9dc21fa757cc4eb44a0cf29d49ec3706eb24be8507c02681f9b204014c48e6c3',
             'langx': 'zh-cn',
             'ltype': '3',
             'gtype': 'FT',
@@ -54,7 +54,7 @@ class ZuqiuSpider(scrapy.Spider):
             for league in leagues:
                 lid = league.xpath('.//league_id/text()').extract_first()
                 from_data = {
-                    'uid': '9965a18b03dc6aacf12290bd5b8267fd7e38ec76eadf899b6108e82da5974cdd',
+                    'uid': '9dc21fa757cc4eb44a0cf29d49ec3706eb24be8507c02681f9b204014c48e6c3',
                     'langx': 'zh-cn',
                     'ltype': '3',
                     'gtype': 'FT',
@@ -77,7 +77,7 @@ class ZuqiuSpider(scrapy.Spider):
         if gids:
             for i, gid in enumerate(gids):
                 from_data = {
-                    'uid': '9965a18b03dc6aacf12290bd5b8267fd7e38ec76eadf899b6108e82da5974cdd',
+                    'uid': '9dc21fa757cc4eb44a0cf29d49ec3706eb24be8507c02681f9b204014c48e6c3',
                     'langx': 'zh-cn',
                     'ltype': '3',
                     'gtype': 'FT',

+ 1 - 1
hgg070_spider/utils/LocalToken.py

@@ -1 +1 @@
-token = {'token': 'JlUo1415650051585d481566c10c9', 'username': 'python', 'password': 'python888', 'token_url': 'http://admin.5gogo.com/getToken'}
+token = {'token': '2F8avN15725967815dbbec2d80aa5', 'username': 'python', 'password': 'python888', 'token_url': 'http://admin.5gogo.com/getToken'}