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