本文整理匯總了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)