def reserve(self, match):
payload = {'match_selected': match['match_id'],
'match_verein_id': '',
'as_values_match_verein_id': '',
'check_match': match['match_id']}
r = self.driver.request("POST", self.baseUrl + '&act=new', data=payload)
doc = lxml.html.fromstring(r.content)
path_match = "/html/body//table//tr[@id]/*//text() | " \
"/html/body//table//tr[@id]/*//@href"
raw = doc.xpath(path_match)
# 2017-06-05 -> 05.06.17
date = datetime.datetime.strptime(match['match_date'], '%Y-%m-%d %H:%M').strftime('%d.%m.%y %H:%M')
# ---- raw snipet -----
# 0 06.06.17 18:30 Uhr
# 1 Relegation
# 2 TSV Landsberg
# 3 - TSV Bogen
# 4 index.php?page=fotograf_spiele&mafo_id=43704&act=del
# 5 Bereits jemand eingetragen:
# 6 http://www.fupa.net/fupaner/abc-def-3
# 7 abc def
# ...
for i, d in enumerate(raw):
if date in d:
if match['home'] in raw[i + 2] and match['guest'] in raw[i + 3]:
url = raw[i + 4]
match['mafo_id'] = url.split("?")[1].split("&")[1].split("=")[1]
try:
if 'Bereits jemand eingetragen' in raw[i + 5]:
# already reserved
return match, raw[i + 7] # Photographer
except:
pass
# match can be reserved
return match, None
评论列表
文章目录