def _xpath_adjacent(self, **kwargs):
from .elements.html_elements import HTMLElement, HTMLElementCollection
import nerodia
plural = kwargs.pop('plural', None)
index = kwargs.pop('index', None)
tag_name = kwargs.get('tag_name')
if not (plural or any(isinstance(val, re._pattern_type) for val in kwargs.values())):
kwargs['index'] = index or 0
if not plural and tag_name:
klass = nerodia.tag_to_class.get(tag_name)
elif not plural:
klass = HTMLElement
elif tag_name:
klass = nerodia.tag_to_class.get('{}_collection'.format(tag_name))
else:
klass = HTMLElementCollection
return klass(self, kwargs)
评论列表
文章目录