本文整理汇总了Python中selection.backend.XpathSelector.number方法的典型用法代码示例。如果您正苦于以下问题:Python XpathSelector.number方法的具体用法?Python XpathSelector.number怎么用?Python XpathSelector.number使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类selection.backend.XpathSelector
的用法示例。
在下文中一共展示了XpathSelector.number方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_selector_number_does_not_exist
# 需要导入模块: from selection.backend import XpathSelector [as 别名]
# 或者: from selection.backend.XpathSelector import number [as 别名]
def test_selector_number_does_not_exist(self):
sel = XpathSelector(self.tree).select("//ul/li[1]").one()
self.assertEquals("DEFAULT", sel.number(default="DEFAULT"))
self.assertRaises(DataNotFound, lambda: sel.number())
示例2: test_number_default
# 需要导入模块: from selection.backend import XpathSelector [as 别名]
# 或者: from selection.backend.XpathSelector import number [as 别名]
def test_number_default(self):
sel = XpathSelector(self.tree).select("//ul/li[10]")
self.assertRaises(DataNotFound, sel.number)
self.assertEquals("DEFAULT", sel.number(default="DEFAULT"))
示例3: test_sel_list_number_does_not_exist
# 需要导入模块: from selection.backend import XpathSelector [as 别名]
# 或者: from selection.backend.XpathSelector import number [as 别名]
def test_sel_list_number_does_not_exist(self):
sel = XpathSelector(self.tree).select('//ul/li[1]')
self.assertEquals('DEFAULT', sel.number(default='DEFAULT'))
self.assertRaises(DataNotFound, lambda: sel.number())
示例4: test_number
# 需要导入模块: from selection.backend import XpathSelector [as 别名]
# 或者: from selection.backend.XpathSelector import number [as 别名]
def test_number(self):
sel = XpathSelector(self.tree).select("//ul/li[4]")
self.assertEquals(4, sel.number())