1 from BeautifulSoup import BeautifulSoup
3 from datetime import time, datetime
10 def __init__(self, html):
11 self.soup = BeautifulSoup(html)
14 for detail in self.details():
18 def _parse_details(self):
19 return self.soup.findAll('div', {'class': 'data_table tourdetail'})
24 self._details = self._parse_details()
28 def _parse_overview(self):
30 Returns dict containing
38 table = self.soup.find('table', {'id': 'tbl_fahrten'})
40 rows = table.findAll('tr')[1:]
41 overview = map(lambda x: {
42 'date': datetime.strptime(x.find('td', {'class': 'col_date'}).text, '%d.%m.%Y'), # grab date
43 'time': map(lambda x: time(*map(lambda x: int(x), x.split(':'))), x.find('td', {'class': 'col_time'}).text.split(' - ')), # extract times
44 'duration': time(*map(lambda x: int(x), x.find('td', {'class': 'col_duration'}).text.split(':'))), # grab duration
45 'change': int(x.find('td', {'class': 'col_change'}).text), # grab changes
46 'price': float(x.find('td', {'class': 'col_price'}).text.replace(',', '.')) # grab price
54 if not self._overview:
55 self._overview = self._parse_overview()
63 raise NotImplementedError