The recipe is implemented in 01/02_events_with_urllib3.py. The code is the following:
import urllib3from bs4 import BeautifulSoupdef get_upcoming_events(url): req = urllib3.PoolManager() res = req.request('GET', url) soup = BeautifulSoup(res.data, 'html.parser') events = soup.find('ul', {'class': 'list-recent-events'}).findAll('li') for event in events: event_details = dict() event_details['name'] = event.find('h3').find("a").text event_details['location'] = event.find('span', {'class', 'event-location'}).text event_details['time'] = event.find('time').text print(event_details)get_upcoming_events('https://www.python.org/events/python-events/')
The run it with the python interpreter. You will get identical output to the previous ...