|
|
发表于 2017-10-26 09:50:32
|
显示全部楼层
- def extract(self):
- """
- Call the ``.extract()`` method for each element is this list and return
- their results flattened, as a list of unicode strings.
- """
- return [x.extract() for x in self]
复制代码
这是选择parsel库的selector.py里的关于类selectorList的extract方法的定义,它是返回一个列表,其中x是selector类的实例,它自己的extract方法具体实现也贴出来
- def extract(self):
- """
- Serialize and return the matched nodes in a single unicode string.
- Percent encoded content is unquoted.
- """
- try:
- return etree.tostring(self.root,
- method=self._tostring_method,
- encoding='unicode',
- with_tail=False)
- except (AttributeError, TypeError):
- if self.root is True:
- return u'1'
- elif self.root is False:
- return u'0'
- else:
- return six.text_type(self.root)
复制代码
总之具体就是经过一系列的处理,返回的就是你text()的内容,你可以用shell状态下进行解析实验,实在想弄懂处理过程,就建议根据上面的分析方法一层层解析 |
|