Skip to content

Commit

Permalink
Update scraper.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tcalil committed Nov 3, 2016
1 parent edbdf62 commit ab295ee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,26 @@
# All that matters is that your final data is written to an SQLite database
# called "data.sqlite" in the current working directory which has at least a table
# called "data".

import scrapy

class RacingItem(scrapy.Item):
fin = scrapy.Field()
runner = scrapy.Field()
odds = scrapy.Field()


class RacingSpider(scrapy.Spider):
name = 'racenet.com.au'
allowed_domains = ['racenet.com.au']
start_urls = ['https://www.racenet.com.au/horse-racing-results/']

def parse(self, response):
for table in response.xpath('.//table[@class="tblLatestHorseResults"]'):
rows = table.xpath('.//tr[@class="tr_res_runner"]')
for row in rows:
item = RacingItem()
item['fin'] = row.xpath('.//td[@class="first"]/text()').extract()
item['runner'] = row.xpath('.//td[2]/a[@class="link_red bold"]/text()').extract()
item['odds'] = row.xpath('.//td[@class="res_odds sb res_td_light last"]/span/text()').extract()
yield item

0 comments on commit ab295ee

Please sign in to comment.