Bladeren bron

fix double

张延森 4 jaren geleden
bovenliggende
commit
4217df5c12

+ 1
- 1
crawl/run.py Bestand weergeven

@@ -7,4 +7,4 @@ print(dirpath)
7 7
 # 添加环境变量
8 8
 sys.path.append(dirpath)
9 9
 # 启动爬虫,第三个参数为爬虫name
10
-execute(['scrapy','crawl','football'])
10
+execute(['scrapy','crawl','lottery'])

BIN
crawl/spiders/__pycache__/football.cpython-38.pyc Bestand weergeven


BIN
crawl/spiders/__pycache__/lottery.cpython-38.pyc Bestand weergeven


+ 18
- 25
crawl/spiders/lottery.py Bestand weergeven

@@ -16,8 +16,16 @@ class LotterySpider(scrapy.Spider):
16 16
     yield scrapy.Request(url, self.parsePermutation, 'POST')
17 17
 
18 18
     # 双色球
19
-    url = "http://www.cwl.gov.cn/cwl_admin/kjxx/findDrawNotice?name=ssq&issueCount=1"
20
-    yield scrapy.Request(url, self.parseDraw)
19
+    url = "https://api.xinti.com/chart/QueryPrizeDetailInfo"
20
+    body = '''
21
+      {
22
+        "ClientSource": 3,
23
+        "Param":{
24
+          "GameCode": "SSQ"
25
+        }
26
+      }
27
+    '''
28
+    yield scrapy.Request(url, self.parseDraw, 'POST', None, body)
21 29
 
22 30
   # 大乐透
23 31
   def parseLottery(self, response):
@@ -87,37 +95,22 @@ class LotterySpider(scrapy.Spider):
87 95
   # 福彩 - 双色球
88 96
   def parseDraw(self, response):
89 97
     data = response.json()
90
-    data = data['result'][0]
98
+    data = data['Value']
91 99
 
92 100
     typ = 'double-color'
93 101
     result = LotteryResult(
94 102
       typ,
95
-      data['code'],
96
-      data['date'][0:10],
97
-      '|'.join(data['red'].split(',') + [data['blue']])
103
+      data['PreIssuseInfo']['IssuseNumber'].replace('-', ''),
104
+      data['PreIssuseInfo']['AwardTime'],
105
+      data['PreIssuseInfo']['WinNumber'].replace(',', '|')
98 106
     )
99 107
 
100 108
     details = []
101
-    for i, item in enumerate(data['prizegrades']):
102
-      level = item.get('type')
103
-      if level == 1:
104
-        level = '一等奖'
105
-      elif level == 2:
106
-        level = '二等奖'
107
-      elif level == 3:
108
-        level = '三等奖'
109
-      elif level == 4:
110
-        level = '四等奖'
111
-      elif level == 5:
112
-        level = '五等奖'
113
-      elif level == 6:
114
-        level = '六等奖'
115
-      else:
116
-        continue
117
-
118
-      detail = LotteryResultDetail(level, item.get('typenum'), item.get('typemoney'))
109
+    for item in data['BonusPoolList']:
110
+      level = item.get('PrizeName')
111
+
112
+      detail = LotteryResultDetail(level, str(item.get('WinCount')), str(item.get('SingleWinBonus')))
119 113
       details.append(detail)
120 114
 
121 115
     result.setDetails(details)
122 116
     result.persist()
123
-