当前位置: 首页>>代码示例>>Python>>正文


Python Node.set_descendants方法代码示例

本文整理汇总了Python中node.Node.set_descendants方法的典型用法代码示例。如果您正苦于以下问题:Python Node.set_descendants方法的具体用法?Python Node.set_descendants怎么用?Python Node.set_descendants使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在node.Node的用法示例。


在下文中一共展示了Node.set_descendants方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_set_descendants_with_simple_html

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import set_descendants [as 别名]
 def test_set_descendants_with_simple_html(self):
     h1_node = Node('bbbbb<h2>cccc</h2>dddd', 'h1')
     h1_node.set_descendants()
     self.assertEqual(h1_node.children[0].html_body, 'dddd')
     self.assertEqual(h1_node.children[0].heading_type, 'h2')
     self.assertEqual(h1_node.children[0].heading_title, 'cccc')
     self.assertEqual(len(h1_node.children), 1)
     self.naver_hay_fever_page = WebPage('http://matome.naver.jp/topic/1LzuV')
开发者ID:katryo,项目名称:task_search,代码行数:10,代码来源:test_node.py

示例2: product_nodes

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import set_descendants [as 别名]
 def product_nodes(self):
     nodes = []
     for i, heading in enumerate(self.headings):
         node = Node(self.html_texts_divided_by_heading[i], self.children_heading_type)
         node.set_heading_title(heading[4:-5])  # <h2>..</h2>のタグ除去
         node.set_descendants()
         nodes.append(node)
     return nodes
开发者ID:katryo,项目名称:task_search,代码行数:10,代码来源:node_factory.py

示例3: test_set_descendants_with_h1_h2_h3

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import set_descendants [as 别名]
 def test_set_descendants_with_h1_h2_h3(self):
     h1_node = Node('a<h2>heading1</h2>b<h3>smallheading1</h3>c<h2>heading2</h2>c<h3>smallheading2</h3>d', 'h1')
     h1_node.set_descendants()
     self.assertEqual(h1_node.children[0].heading_title, 'heading1')
     self.assertEqual(h1_node.children[0].children[0].heading_title, 'smallheading1')
     self.assertEqual(h1_node.children[1].heading_title, 'heading2')
     self.assertEqual(h1_node.children[1].children[0].heading_title, 'smallheading2')
     self.assertEqual(len(h1_node.children), 2)
     self.assertEqual(len(h1_node.children[0].children), 1)
     self.assertEqual(len(h1_node.children[1].children), 1)
开发者ID:katryo,项目名称:task_search,代码行数:12,代码来源:test_node.py

示例4: test_set_descendants_with_h1_and_h2

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import set_descendants [as 别名]
 def test_set_descendants_with_h1_and_h2(self):
     h1_node = Node('<html>a<h2>heading1</h2>b<h2>heading2</h2>c</html>', 'h1')
     h1_node.set_descendants()
     self.assertEqual(h1_node.children[0].html_body, 'b')
     self.assertEqual(h1_node.children[0].heading_type, 'h2')
     self.assertEqual(h1_node.children[0].heading_title, 'heading1')
     self.assertEqual(h1_node.children[1].html_body, 'c</html>')
     self.assertEqual(h1_node.children[1].heading_type, 'h2')
     self.assertEqual(h1_node.children[1].heading_title, 'heading2')
     self.assertEqual(len(h1_node.children), 2)
开发者ID:katryo,项目名称:task_search,代码行数:12,代码来源:test_node.py

示例5: test_set_descendants_with_h3_h5

# 需要导入模块: from node import Node [as 别名]
# 或者: from node.Node import set_descendants [as 别名]
 def test_set_descendants_with_h3_h5(self):
     h1_node = Node('<h3>heading3</h3><h5>heading5</h5>', 'h1')
     h1_node.set_descendants()
     self.assertEqual(h1_node.children[0].heading_title, 'heading3')
     self.assertEqual(h1_node.children[0].children[0].heading_title, 'heading5')
开发者ID:katryo,项目名称:task_search,代码行数:7,代码来源:test_node.py


注:本文中的node.Node.set_descendants方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。