Я пытаюсь использовать Rule
и LinkExtractor
для извлечения ссылок, это мой код в оболочке Scrapy
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']