get_next_source

This commit is contained in:
James Turk 2021-06-05 01:35:34 -04:00
parent a83ee7f81c
commit 5a0b666e65

View File

@ -1,5 +1,5 @@
# imports we'll use in this example # imports we'll use in this example
from spatula import HtmlPage, HtmlListPage, CSS, XPath from spatula import HtmlPage, HtmlListPage, CSS, XPath, SelectorError
class EmployeeList(HtmlListPage): class EmployeeList(HtmlListPage):
@ -24,6 +24,12 @@ class EmployeeList(HtmlListPage):
source=XPath("./a/@href").match_one(details), source=XPath("./a/@href").match_one(details),
) )
def get_next_source(self):
try:
return XPath("//a[contains(text(), 'Next')]/@href").match_one(self.root)
except SelectorError:
pass
class EmployeeDetail(HtmlPage): class EmployeeDetail(HtmlPage):
def process_page(self): def process_page(self):