Pārlūkot izejas kodu

Merge branch 'dev' of http://git.ycjcjy.com/niucai/crawl into dev

张延森 4 gadus atpakaļ
vecāks
revīzija
369db317fa

Binārs
crawl/__pycache__/__init__.cpython-38.pyc Parādīt failu


Binārs
crawl/__pycache__/settings.cpython-38.pyc Parādīt failu


Binārs
crawl/comm/__pycache__/__init__.cpython-38.pyc Parādīt failu


Binārs
crawl/comm/__pycache__/basketball.cpython-38.pyc Parādīt failu


Binārs
crawl/comm/__pycache__/football.cpython-38.pyc Parādīt failu


Binārs
crawl/comm/__pycache__/lottery.cpython-38.pyc Parādīt failu


Binārs
crawl/comm/__pycache__/mydb.cpython-38.pyc Parādīt failu


+ 1
- 1
crawl/run.py Parādīt failu

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

Binārs
crawl/spiders/__pycache__/__init__.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/basketball_match.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/basketball_price.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/basketball_result.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/football.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/football_match.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/football_price.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/football_result.cpython-38.pyc Parādīt failu


Binārs
crawl/spiders/__pycache__/lottery.cpython-38.pyc Parādīt failu


+ 2
- 2
crawl/spiders/basketball_match.py Parādīt failu

26
       matchWeek = prop[0].css('::text').get()
26
       matchWeek = prop[0].css('::text').get()
27
       league = prop[1].css('::text').get()
27
       league = prop[1].css('::text').get()
28
       team = prop[2].css('::text').get().split('VS')
28
       team = prop[2].css('::text').get().split('VS')
29
-      homeTeam = team[0].strip()
30
-      awayTeam = team[1].strip()
29
+      homeTeam = team[1].strip()
30
+      awayTeam = team[0].strip()
31
       matchTime = prop[3].css('::text').get()
31
       matchTime = prop[3].css('::text').get()
32
       status = prop[5].css('::text').get()
32
       status = prop[5].css('::text').get()
33
       wl = self.parsePassWay(prop[6].css('img'))
33
       wl = self.parsePassWay(prop[6].css('img'))

+ 9
- 3
crawl/spiders/football_result.py Parādīt failu

1
 import scrapy
1
 import scrapy
2
 import re
2
 import re
3
+import logging
3
 from crawl.comm.football import FTResult
4
 from crawl.comm.football import FTResult
4
 
5
 
5
 class FootballSpider(scrapy.Spider):
6
 class FootballSpider(scrapy.Spider):
28
       awayTeam = self.trimBrackets(tdNodeList[3].css('.ke::text').get()) # 客队
29
       awayTeam = self.trimBrackets(tdNodeList[3].css('.ke::text').get()) # 客队
29
       half = tdNodeList[4].css('span::text').get()
30
       half = tdNodeList[4].css('span::text').get()
30
       whole = tdNodeList[5].css('span::text').get()
31
       whole = tdNodeList[5].css('span::text').get()
31
-      status = tdNodeList[9].css('span::text').get()
32
+      status = tdNodeList[9].css('::text').get()
32
 
33
 
33
-      FTResult(
34
+      ftResult = FTResult(
34
         matchTime,
35
         matchTime,
35
         matchWeek,
36
         matchWeek,
36
         leagueName,
37
         leagueName,
40
         half,
41
         half,
41
         whole,
42
         whole,
42
         status
43
         status
43
-      ).persist()
44
+      )
45
+      
46
+      logging.info("采集到数据 --> %s" % ftResult.toString())
47
+
48
+      ftResult.persist()
49
+
44
 
50
 
45
     # 是否存在下一页
51
     # 是否存在下一页
46
     pgNodes = response.css('.m-page .u-pg2')
52
     pgNodes = response.css('.m-page .u-pg2')