Skip to content

Instantly share code, notes, and snippets.

@p7k
Created February 22, 2011 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p7k/838884 to your computer and use it in GitHub Desktop.
Save p7k/838884 to your computer and use it in GitHub Desktop.
def parse_event(self, response):
# self.log('Hi, this is an event page! %s' % response.url)
hxs = HtmlXPathSelector(response)
event_view_div = hxs.select('//div[@class="event_view"]')
event = Event()
event_loader = XPathItemLoader(event, event_view_div)
event_loader.add_value('source', self.name)
event_loader.add_value('guid', response.url)
event_loader.add_value('url', response.url)
event_loader.add_xpath('title', '//div[@class="event_view_head"]//h1[@class="headline title"]/a/text()')
event_loader.add_xpath('description', '//div[@class="event_article"]//p[@class="description"]/text()')
event_loader.load_item()
location_url = event_view_div.select('//div[@class="event_view"]//span[@class="sm_venue"]/a[contains(@href, "/locations/")]/@href').extract()[0]
yield Request('/'.join((base_url, location_url)), callback=self.parse_location, meta={'event': event})
yield event
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment