浏览代码

fix double

张延森 4 年前
父节点
当前提交
4217df5c12
共有 4 个文件被更改,包括 19 次插入26 次删除
  1. 1
    1
      crawl/run.py
  2. 二进制
      crawl/spiders/__pycache__/football.cpython-38.pyc
  3. 二进制
      crawl/spiders/__pycache__/lottery.cpython-38.pyc
  4. 18
    25
      crawl/spiders/lottery.py

+ 1
- 1
crawl/run.py 查看文件

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

二进制
crawl/spiders/__pycache__/football.cpython-38.pyc 查看文件


二进制
crawl/spiders/__pycache__/lottery.cpython-38.pyc 查看文件


+ 18
- 25
crawl/spiders/lottery.py 查看文件

16
     yield scrapy.Request(url, self.parsePermutation, 'POST')
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
   def parseLottery(self, response):
31
   def parseLottery(self, response):
87
   # 福彩 - 双色球
95
   # 福彩 - 双色球
88
   def parseDraw(self, response):
96
   def parseDraw(self, response):
89
     data = response.json()
97
     data = response.json()
90
-    data = data['result'][0]
98
+    data = data['Value']
91
 
99
 
92
     typ = 'double-color'
100
     typ = 'double-color'
93
     result = LotteryResult(
101
     result = LotteryResult(
94
       typ,
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
     details = []
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
       details.append(detail)
113
       details.append(detail)
120
 
114
 
121
     result.setDetails(details)
115
     result.setDetails(details)
122
     result.persist()
116
     result.persist()
123
-