@@ -0,0 +1,2537 @@
+from itertools import chain, izip%0A%0Afrom scrapy import Item, Field%0Afrom scrapy.contrib.spiders import CrawlSpider, Rule%0Afrom scrapy.contrib.linkextractors import LinkExtractor%0A%0Acolumns_by_pos = %7B%0A    'QB': %5B%0A        'week',%0A        'passing_cmp_passing_att',%0A        'passing_yds',%0A        'passing_tds',%0A        'passing_ints',%0A        'rushing_atts',%0A        'rushing_yds',%0A        'rushing_tds',%0A        'fp_ci',%0A        'fp',%0A    %5D,%0A    'RB': %5B%0A        'week',%0A        'rushing_atts',%0A        'rushing_yds',%0A        'rushing_tds',%0A        'recs',%0A        'receiving_yds',%0A        'receiving_tds',%0A        'fp_ci',%0A        'fp',%0A    %5D,%0A    'WR': %5B%0A        'week',%0A        'recs',%0A        'receiving_yds',%0A        'receiving_tds',%0A        'fp_ci',%0A        'fp',%0A    %5D,%0A    'K': %5B%0A        'week',%0A        'fgm',%0A        'fga',%0A        'xpm',%0A        'fp_ci',%0A        'fp',%0A    %5D,%0A    'D': %5B%0A        'week',%0A        'defense_pts_against',%0A        'defense_sk',%0A        'defense_ints',%0A        'defense_frec',%0A        'defense_tds',%0A        'fp_ci',%0A        'fp',%0A    %5D%0A%7D%0Acolumns_by_pos%5B'TE'%5D = columns_by_pos%5B'WR'%5D%0Aall_fields = set(chain.from_iterable(columns_by_pos.itervalues()))%0Aall_fields.update(%5B'name', 'team', 'pos'%5D)%0A%0A%0Adef PlayerRow(**fields):%0A    item = Item()%0A    for field in all_fields:%0A        item.fields%5Bfield%5D = Field()%0A    for field, value in fields.iteritems():%0A        item%5Bfield%5D = value%0A    return item%0A%0A%0Aclass NumberfireSpider(CrawlSpider):%0A    name = 'numberfire_spider'%0A    start_urls = %5B%0A        'http://www.numberfire.com/nfl/players/',%0A    %5D%0A    allowed_domains = %5B'numberfire.com'%5D%0A%0A    rules = %5B%0A        Rule(LinkExtractor(%0A            allow=r'%5Ehttp://www%5C.numberfire%5C.com/nfl/players/%5B%5Cw-%5D+$',%0A            restrict_xpaths='//*%5B@id=%22browse-players%22%5D',%0A            ), 'parse_player',%0A        ),%0A    %5D%0A%0A    def __init__(self, *args, **kwargs):%0A        super(NumberfireSpider, self).__init__(*args, **kwargs)%0A%0A    def parse_player(self, response):%0A        name = response.xpath('//*%5B@id=%22player-headline%22%5D/tbody/tr/td%5B2%5D/h3/span%5B1%5D/text()').extract()%5B0%5D%0A        pos, team = response.xpath('//*%5B@id=%22player-headline%22%5D/tbody/tr/td%5B2%5D/h3/span%5B2%5D/text()').extract()%5B0%5D%5C%0A            .strip('()').split(',')%0A%0A        for row in response.xpath('//*%5B@id=%22this-week%22%5D%5B2%5D/table/tbody/tr'):%0A            player_row = PlayerRow(name=name, pos=pos, team=team)%0A            for field, value in izip(columns_by_pos%5Bpos%5D, row.xpath('./td/text()').extract()):%0A                player_row%5Bfield%5D = value%0A            yield player_row%0A

add numberfire spider