How to do it...

The script for this recipe is 01/03_events_with_scrapy.py. The following is the code:

import scrapyfrom scrapy.crawler import CrawlerProcessclass PythonEventsSpider(scrapy.Spider):    name = 'pythoneventsspider'    start_urls = ['https://www.python.org/events/python-events/',]    found_events = []    def parse(self, response):        for event in response.xpath('//ul[contains(@class, "list-recent-events")]/li'):            event_details = dict()            event_details['name'] = event.xpath('h3[@class="event-title"]/a/text()').extract_first()            event_details['location'] = event.xpath('p/span[@class="event-location"]/text()').extract_first()            event_details['time'] = event.xpath('p/time/text()').extract_first()            self.found_events.append(event_details)if __name__ ==  ...

Get Python Web Scraping Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.