|
@@ -35,12 +35,11 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
def start_requests(self):
|
|
def start_requests(self):
|
|
|
url = "http://m.hgg070.com/app/member/get_league_list.php"
|
|
url = "http://m.hgg070.com/app/member/get_league_list.php"
|
|
|
h_types = [('FT', '', '130'), ('FU', 'P', '131'), ('FU', "", '130'), ('FU', 'P', '131')]
|
|
h_types = [('FT', '', '130'), ('FU', 'P', '131'), ('FU', "", '130'), ('FU', 'P', '131')]
|
|
|
- for h_type in h_types:
|
|
|
|
|
- # show_type, isp, length = h_type
|
|
|
|
|
- show_type, isp, length = h_types[3]
|
|
|
|
|
|
|
+ for i, h_type in enumerate(h_types):
|
|
|
|
|
+ show_type, isp, length = h_type
|
|
|
self.headers['Content-Length'] = length
|
|
self.headers['Content-Length'] = length
|
|
|
from_data = {
|
|
from_data = {
|
|
|
- 'uid': '013dc3a00cbd488238236010f78ab4a41af7e6ff05ceb96bc0854b60807a42eb',
|
|
|
|
|
|
|
+ 'uid': '4d6e7f8af34715653b6039ca9b43737f096ed82446e3d37e033349aba0e3e753',
|
|
|
'langx': 'zh-cn',
|
|
'langx': 'zh-cn',
|
|
|
'ltype': '3',
|
|
'ltype': '3',
|
|
|
'gtype': 'FT',
|
|
'gtype': 'FT',
|
|
@@ -50,33 +49,32 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
'isP': isp
|
|
'isP': isp
|
|
|
}
|
|
}
|
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse, headers=self.headers,
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse, headers=self.headers,
|
|
|
- meta={'showtype': show_type, 'isp': isp}, dont_filter=True)
|
|
|
|
|
|
|
+ meta={'index': i}, dont_filter=True)
|
|
|
|
|
|
|
|
def parse(self, response):
|
|
def parse(self, response):
|
|
|
- if response.status == 400:
|
|
|
|
|
- print(response.status)
|
|
|
|
|
- print('parse', response.url)
|
|
|
|
|
leagues = response.xpath('//serverresponse/game/league')
|
|
leagues = response.xpath('//serverresponse/game/league')
|
|
|
url = 'http://m.hgg070.com/app/member/get_game_list.php'
|
|
url = 'http://m.hgg070.com/app/member/get_game_list.php'
|
|
|
if leagues:
|
|
if leagues:
|
|
|
- showtype = response.meta['showtype']
|
|
|
|
|
- isp = response.meta['isp']
|
|
|
|
|
- if showtype == 'FT' and isp == '':
|
|
|
|
|
|
|
+ index = response.meta['index']
|
|
|
|
|
+ if index == 0:
|
|
|
date = ''
|
|
date = ''
|
|
|
|
|
+ showtype = 'FT'
|
|
|
|
|
+ isp = ''
|
|
|
self.headers['Content-Length'] = '147'
|
|
self.headers['Content-Length'] = '147'
|
|
|
- elif showtype == 'FU' and isp == 'P':
|
|
|
|
|
- date = 'all'
|
|
|
|
|
- self.headers['Content-Length'] = '151'
|
|
|
|
|
- elif showtype == 'FU' and isp == '':
|
|
|
|
|
|
|
+ elif index == 2:
|
|
|
date = 'all'
|
|
date = 'all'
|
|
|
|
|
+ showtype = 'FU'
|
|
|
|
|
+ isp = ''
|
|
|
self.headers['Content-Length'] = '150'
|
|
self.headers['Content-Length'] = '150'
|
|
|
else:
|
|
else:
|
|
|
date = 'all'
|
|
date = 'all'
|
|
|
|
|
+ showtype = 'FU'
|
|
|
|
|
+ isp = 'P'
|
|
|
self.headers['Content-Length'] = '151'
|
|
self.headers['Content-Length'] = '151'
|
|
|
for league in leagues:
|
|
for league in leagues:
|
|
|
lid = league.xpath('.//league_id/text()').extract_first()
|
|
lid = league.xpath('.//league_id/text()').extract_first()
|
|
|
from_data = {
|
|
from_data = {
|
|
|
- 'uid': '013dc3a00cbd488238236010f78ab4a41af7e6ff05ceb96bc0854b60807a42eb',
|
|
|
|
|
|
|
+ 'uid': '4d6e7f8af34715653b6039ca9b43737f096ed82446e3d37e033349aba0e3e753',
|
|
|
'langx': 'zh-cn',
|
|
'langx': 'zh-cn',
|
|
|
'ltype': '3',
|
|
'ltype': '3',
|
|
|
'gtype': 'FT',
|
|
'gtype': 'FT',
|
|
@@ -87,35 +85,40 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
'isP': isp
|
|
'isP': isp
|
|
|
}
|
|
}
|
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse_match, headers=self.headers,
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse_match, headers=self.headers,
|
|
|
- meta={'showtype': showtype, 'isp': isp}, dont_filter=True)
|
|
|
|
|
|
|
+ meta={'index': index}, dont_filter=True)
|
|
|
else:
|
|
else:
|
|
|
print('未获取到联赛id')
|
|
print('未获取到联赛id')
|
|
|
return
|
|
return
|
|
|
|
|
|
|
|
def parse_match(self, response):
|
|
def parse_match(self, response):
|
|
|
- if response.status == 400:
|
|
|
|
|
- print(response.status)
|
|
|
|
|
- print('parse_match', response.url)
|
|
|
|
|
|
|
+ index = response.meta['index']
|
|
|
url = 'http://m.hgg070.com/app/member/get_game_more.php'
|
|
url = 'http://m.hgg070.com/app/member/get_game_more.php'
|
|
|
- showtype = response.meta['showtype']
|
|
|
|
|
- isp = response.meta['isp']
|
|
|
|
|
- if showtype == 'FT' and isp == '':
|
|
|
|
|
|
|
+ if index == 0:
|
|
|
date = ''
|
|
date = ''
|
|
|
|
|
+ showtype = 'FT'
|
|
|
|
|
+ isp = ''
|
|
|
self.headers['Content-Length'] = '132'
|
|
self.headers['Content-Length'] = '132'
|
|
|
- elif showtype == 'FU' and isp == 'P':
|
|
|
|
|
|
|
+ elif index == 1:
|
|
|
date = 'all'
|
|
date = 'all'
|
|
|
|
|
+ showtype = 'FT'
|
|
|
|
|
+ isp = 'P'
|
|
|
self.headers['Content-Length'] = '136'
|
|
self.headers['Content-Length'] = '136'
|
|
|
- elif showtype == 'FU' and isp == '':
|
|
|
|
|
|
|
+ elif index == 2:
|
|
|
date = ''
|
|
date = ''
|
|
|
|
|
+ showtype = 'FU'
|
|
|
|
|
+ isp = ''
|
|
|
self.headers['Content-Length'] = '132'
|
|
self.headers['Content-Length'] = '132'
|
|
|
else:
|
|
else:
|
|
|
date = 'all'
|
|
date = 'all'
|
|
|
|
|
+ showtype = 'FU'
|
|
|
|
|
+ isp = 'P'
|
|
|
self.headers['Content-Length'] = '136'
|
|
self.headers['Content-Length'] = '136'
|
|
|
gids = response.xpath('//serverresponse/game/gid/text()').extract()
|
|
gids = response.xpath('//serverresponse/game/gid/text()').extract()
|
|
|
|
|
+ tags = response.xpath('//serverresponse/game/more_count/text()').extract()
|
|
|
if gids:
|
|
if gids:
|
|
|
- for gid in gids:
|
|
|
|
|
|
|
+ for i, gid in enumerate(gids):
|
|
|
from_data = {
|
|
from_data = {
|
|
|
- 'uid': '013dc3a00cbd488238236010f78ab4a41af7e6ff05ceb96bc0854b60807a42eb',
|
|
|
|
|
|
|
+ 'uid': '4d6e7f8af34715653b6039ca9b43737f096ed82446e3d37e033349aba0e3e753',
|
|
|
'langx': 'zh-cn',
|
|
'langx': 'zh-cn',
|
|
|
'ltype': '3',
|
|
'ltype': '3',
|
|
|
'gtype': 'FT',
|
|
'gtype': 'FT',
|
|
@@ -124,16 +127,17 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
'isP': isp,
|
|
'isP': isp,
|
|
|
'gid': gid,
|
|
'gid': gid,
|
|
|
}
|
|
}
|
|
|
|
|
+ tag = tags[i]
|
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse_odds, headers=self.headers,
|
|
yield scrapy.FormRequest(url=url, formdata=from_data, callback=self.parse_odds, headers=self.headers,
|
|
|
- meta={'showtype': showtype, 'isp': isp}, dont_filter=True)
|
|
|
|
|
|
|
+ meta={'index': index, 'tag': tag}, dont_filter=True)
|
|
|
|
|
|
|
|
def parse_odds(self, response):
|
|
def parse_odds(self, response):
|
|
|
- # print(response.text)
|
|
|
|
|
- # game_lists = []
|
|
|
|
|
- if response.status == 400:
|
|
|
|
|
- print(response.status)
|
|
|
|
|
- print('parse_odds', response.url)
|
|
|
|
|
- game = response.xpath('//serverresponse/game')[0]
|
|
|
|
|
|
|
+ index = response.meta['index']
|
|
|
|
|
+ tag = response.meta['tag']
|
|
|
|
|
+ try:
|
|
|
|
|
+ game = response.xpath('//serverresponse/game')[0]
|
|
|
|
|
+ except:
|
|
|
|
|
+ return
|
|
|
logger = logging.getLogger(__name__)
|
|
logger = logging.getLogger(__name__)
|
|
|
if game:
|
|
if game:
|
|
|
game_odds = {}
|
|
game_odds = {}
|
|
@@ -148,5 +152,7 @@ class ZuqiuSpider(scrapy.Spider):
|
|
|
else:
|
|
else:
|
|
|
logger.info('gopen == "N", 详细赔率盘口未开启')
|
|
logger.info('gopen == "N", 详细赔率盘口未开启')
|
|
|
item = ZuqiuItem()
|
|
item = ZuqiuItem()
|
|
|
- item['all'] = game_odds
|
|
|
|
|
|
|
+ item['data'] = game_odds
|
|
|
|
|
+ item['index'] = index
|
|
|
|
|
+ item['tag'] = tag
|
|
|
yield item
|
|
yield item
|