do not follow spam links

This commit is contained in:
Romain Bignon 2013-08-07 19:06:34 +02:00
commit e1eb1b80af
2 changed files with 10 additions and 9 deletions

View file

@ -140,8 +140,7 @@ class Cragr(BaseBrowser):
accounts_list.extend(self.page.get_list()) accounts_list.extend(self.page.get_list())
# credit cards # credit cards
cards_page = self.page.cards_page() for cards_page in self.page.cards_pages():
if cards_page:
self.location(cards_page) self.location(cards_page)
assert self.is_on_page(CardsPage) assert self.is_on_page(CardsPage)
accounts_list.extend(self.page.get_list()) accounts_list.extend(self.page.get_list())

View file

@ -102,13 +102,15 @@ class _AccountsPage(BasePage):
yield account yield account
def cards_page(self): def cards_pages(self):
try: for line in self.document.xpath('//table[@class="ca-table"]/tr[@class="ligne-connexe"]'):
return self.document.xpath('//table[@class="ca-table"]' + try:
'/tr[@class="ligne-connexe"]' + link = line.xpath('.//a/@href')[0]
'//a/@href')[0] except IndexError:
except IndexError: pass
pass else:
if not link.startswith('javascript:'):
yield link
class CardsPage(BasePage): class CardsPage(BasePage):