首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何知道哪些链接是通过scrapy规则提取的

如何知道哪些链接是通过scrapy规则提取的
EN

Stack Overflow用户
提问于 2019-07-10 03:00:55
回答 1查看 109关注 0票数 2

我正在尝试使用RuleLinkExtractor来提取链接,这是我在scrapy shell中的代码

代码语言:javascript
复制
from urllib.parse import quote
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
url= f'https://www.google.com/search?q={quote("Hello World")}'
fetch(url)
x=LinkExtractor(restrict_xpaths='//div[@class="r"]/a')
y=Rule(x)

我试着使用dir(x)来看看我能在上面应用什么方法,我能找到的最好的是x.__sizeof__(),但这显示了32个链接,而不是实际的10个链接。我的问题是,我如何才能找出使用它们实际提取了哪些链接(如列表)。这是dir(x)显示的内容

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_csstranslator', '_extract_links', '_link_allowed', '_process_links', 'allow_domains', 'allow_res', 'canonicalize', 'deny_domains', 'deny_extensions', 'deny_res', 'extract_links', 'link_extractor', 'matches', 'restrict_xpaths']

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56959097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档