Created
April 22, 2014 08:53
-
-
Save ianseyer/11170743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scrapy.spider import Spider | |
from scrapy.http import Request | |
from scrapy.selector import Selector | |
class CampUSA(Spider): | |
""" | |
This spider iterates through the list of states on the homepage, and plunges into each one. It then blindly clicks search to bring up ALL results for that state. | |
""" | |
name = 'camp' | |
allowed_domains = ['campusa.com'] | |
start_urls = [ | |
'http://www.campusa.com', | |
] | |
def parse(self, response): | |
sel = Selector(response) | |
states = [sel.xpath('/html/body/table/tbody/tr/td/table/tbody/tr[1]/td/table/tbody/tr[6]/td[2]/table/tbody/tr/td[2]/li['+str(num)+']/a/@href').extract() for num in range(1, 51)] | |
print states | |
yield (Request(state, self.parse) for state in states) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment