本文整理汇总了Python中cssselect.HTMLTranslator方法的典型用法代码示例。如果您正苦于以下问题:Python cssselect.HTMLTranslator方法的具体用法?Python cssselect.HTMLTranslator怎么用?Python cssselect.HTMLTranslator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cssselect
的用法示例。
在下文中一共展示了cssselect.HTMLTranslator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import cssselect [as 别名]
# 或者: from cssselect import HTMLTranslator [as 别名]
def __init__(self, config={}, html='', query=''):
"""Create new Parser instance and parse all information."""
self.config = config
self.searchtype = self.config.get('search_type', 'normal')
assert self.searchtype in self.search_types, 'search type "{}" is not supported in {}'.format(
self.searchtype,
self.__class__.__name__
)
self.query = query
self.html = html
self.dom = None
self.search_results = {}
self.num_results_for_query = ''
self.num_results = 0
self.effective_query = ''
self.page_number = -1
self.no_results = False
self.related_keywords = {}
# to be set by the implementing sub classes
self.search_engine = ''
# short alias because we use it so extensively
self.css_to_xpath = HTMLTranslator().css_to_xpath
if self.html:
self.parse()
示例2: css
# 需要导入模块: import cssselect [as 别名]
# 或者: from cssselect import HTMLTranslator [as 别名]
def css(self, css):
return etree.XPath(HTMLTranslator().css_to_xpath(css))(self.tree)