我认为我需要做的事情非常简单,但我很难找到任何不仅仅关注于单个域的好源。如何从Scrapy域名列表中获取所有链接?
我有一个约9,000个域名的列表。对于他们每个人,我必须检查一下到我的网站的链接是否存在于他们网域的任何地方。基本上,我需要列表中链接到我的网站的列表中的网站。所以,虽然URL的输入是9000,但我的代码的结果会小得多。
如何开始做这个任何提示,非常感谢。我已经完成了多个Scrapy教程,但这并不是我发现的信息。
编辑 - 这里是我目前正与蜘蛛:
# -*- coding: utf-8 -*-
import scrapy
from scrapy.linkextractors import LinkExtractor
from scrapy.spiders import CrawlSpider, Rule
from urllib.parse import urlparse
class JakeSpider(CrawlSpider):
name = 'jake'
allowed_domains = ['hivedigital.com','gofishdigital.com','quizzly.co']
start_urls = ['http://hivedigital.com/', 'http://gofishdigital.com/', 'https://quizzly.co/']
rules = (
Rule(LinkExtractor(allow=()), callback='parse_item', follow=True),
)
def parse_item(self, response):
#i = {}
page = response.url
domain = urlparse(page).netloc
print("............", domain)
links = response.xpath('//a/@href').extract()
#i['name'] = response.xpath('//div[@id="name"]').extract()
#i['description'] = response.xpath('//div[@id="description"]').extract()
#return i
le = LinkExtractor()
for link in le.extract_links(response):
if link.url == 'http://twitter.com':
yield {'link':link,'domain': domain}
难道只是把它们全部放在allowed_domains和start_urls中吗? –