def iter_books(self, el, start): for tr in self.document.getroot().xpath(el): book = Book(tr[start].text) book.name = tr[start + 3].text book.author = tr[start + 4].text book.date = txt2date(tr[start + 5].text) yield book
def iter_books(self, el, start): for tr in self.document.getroot().xpath(el): book = Book(tr[start].text) book.name = tr[start+3].text book.author = tr[start+4].text book.date = txt2date(tr[start+5].text) yield book
def get_list(self): for tr in self.document.getroot().xpath('//tr[@class="patFuncEntry"]'): id = tr.xpath('td/input')[0].attrib["value"] book = Book(id) bigtitle = tr.xpath('td[@class="patFuncTitle"]/label/a')[0].text book.name = bigtitle.split('/')[0] book.author = bigtitle.split('/')[1] date = tr.xpath('td[@class="patFuncStatus"]')[0].text book.date = txt2date(date.replace('RETOUR', '')) yield book
def get_list(self): for tr in self.document.getroot().xpath('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl09_COMPTE_INFOS_0_GrilleInfos_ctl00__0")]'): username=tr[1].text+"_"+tr[0].text for i, tr in enumerate(self.document.getroot().xpath('//tr[contains(@id, "ctl00_ContentPlaceHolder1_ctl00_ctl10_COMPTE_RESA_1_1_GrilleResas_ctl00__")]')): book = Book('%s%d' % (username, i)) # if all the books booked are available, there are only 7 columns. # if (at least ?) one book is still not available, yous can cancel, and the first column does contain the checkbox. So 8 columns. if (len(tr) == 7): start = 2 if (len(tr) == 8): start = 3 book.name = tr[start].text book.author = tr[start+1].text book.date = txt2date(tr[start+3].text) book.late = False yield book