爬网和爬网

我正在尝试通过scrapy爬行网站上的一些数据。我已经在下面创建了代码,但是我的代码并没有随抓取的数据而变化,因此欢迎您提供有关我在下面定义的代码的任何反馈。

import scrapy
from scrapy.selector import Selector
from artistlist.items import ArtistlistItem

class ArtistlistSpider(scrapy.Spider):
    name = "artistlist"
    allowed_domains = ["digital.rigabiennial.com"]
    start_urls = ['https://digital.rigabiennial.com/02/00',
'https://digital.rigabiennial.com/04/00']

    def parse(self, response):
        titles = response.xpath("//div[@class='margin-bottom-2']")
        for titles in titles:
            item = ArtistlistItem()
            item['artist'] = response.css('h2::text').extract()
            item['biography'] = response.css('p::text').extract()
            yield item

当我从我的scrapy框架运行代码时出现的代码输出。似乎我无法定义正确的标签:

2020-02-07 01:42:28 [scrapy.utils.log] INFO: Scrapy 1.6.0 started (bot: artistlist)
2020-02-07 01:42:28 [scrapy.utils.log] INFO: Versions: lxml 4.3.4.0, libxml2 2.9.9, cssselect 1.0.3, parsel 1.5.1, w3lib 1.20.0, Twisted 19.2.1, Python 3.6.9 (default, Nov  7 2019, 10:44:02) - [GCC 8.3.0], pyOpenSSL 18.0.0 (OpenSSL 1.1.1b  26 Feb 2019), cryptography 2.6.1, Platform Linux-4.15.0-20-generic-x86_64-with-LinuxMint-19.3-tricia
2020-02-07 01:42:28 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'artistlist', 'FEED_FORMAT': 'csv', 'FEED_URI': 'mydata1.csv', 'NEWSPIDER_MODULE': 'artistlist.spiders', 'ROBOTSTXT_OBEY': True, 'SPIDER_MODULES': ['artistlist.spiders']}
2020-02-07 01:42:28 [scrapy.extensions.telnet] INFO: Telnet Password: 1f41c3833f0d08be
2020-02-07 01:42:28 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
 'scrapy.extensions.telnet.TelnetConsole',
 'scrapy.extensions.memusage.MemoryUsage',
 'scrapy.extensions.feedexport.FeedExporter',
 'scrapy.extensions.logstats.LogStats']
2020-02-07 01:42:29 [scrapy.middleware] INFO: Enabled downloader middlewares:
['scrapy.downloadermiddlewares.robotstxt.RobotsTxtMiddleware',
 'scrapy.downloadermiddlewares.httpauth.HttpAuthMiddleware',
 'scrapy.downloadermiddlewares.downloadtimeout.DownloadTimeoutMiddleware',
 'scrapy.downloadermiddlewares.defaultheaders.DefaultHeadersMiddleware',
 'scrapy.downloadermiddlewares.useragent.UserAgentMiddleware',
 'scrapy.downloadermiddlewares.retry.RetryMiddleware',
 'scrapy.downloadermiddlewares.redirect.MetaRefreshMiddleware',
 'scrapy.downloadermiddlewares.httpcompression.HttpCompressionMiddleware',
 'scrapy.downloadermiddlewares.redirect.RedirectMiddleware',
 'scrapy.downloadermiddlewares.cookies.CookiesMiddleware',
 'scrapy.downloadermiddlewares.httpproxy.HttpProxyMiddleware',
 'scrapy.downloadermiddlewares.stats.DownloaderStats']
2020-02-07 01:42:29 [scrapy.middleware] INFO: Enabled spider middlewares:
['scrapy.spidermiddlewares.httperror.HttpErrorMiddleware',
 'scrapy.spidermiddlewares.offsite.OffsiteMiddleware',
 'scrapy.spidermiddlewares.referer.RefererMiddleware',
 'scrapy.spidermiddlewares.urllength.UrlLengthMiddleware',
 'scrapy.spidermiddlewares.depth.DepthMiddleware']
2020-02-07 01:42:29 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2020-02-07 01:42:29 [scrapy.core.engine] INFO: Spider opened
2020-02-07 01:42:29 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2020-02-07 01:42:29 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2020-02-07 01:42:31 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://digital.rigabiennial.com/robots.txt> (referer: None)
2020-02-07 01:42:31 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://digital.rigabiennial.com/02/00> (referer: None)
2020-02-07 01:42:32 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://digital.rigabiennial.com/04/00> (referer: None)
2020-02-07 01:42:32 [scrapy.core.engine] INFO: Closing spider (finished)
2020-02-07 01:42:32 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 689,
 'downloader/request_count': 3,
 'downloader/request_method_count/GET': 3,
 'downloader/response_bytes': 2628,
 'downloader/response_count': 3,
 'downloader/response_status_count/200': 3,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2020, 2, 7, 0, 42, 32, 193136),
 'log_count/DEBUG': 3,
 'log_count/INFO': 9,
 'memusage/max': 53813248,
 'memusage/startup': 53813248,
 'response_received_count': 3,
 'robotstxt/request_count': 1,
 'robotstxt/response_count': 1,
 'robotstxt/response_status_count/200': 1,
 'scheduler/dequeued': 2,`enter code here`
 'scheduler/dequeued/memory': 2,
 'scheduler/enqueued': 2,
 'scheduler/enqueued/memory': 2,
 'start_time': datetime.datetime(2020, 2, 7, 0, 42, 29, 168953)}
2020-02-07 01:42:32 [scrapy.core.engine] INFO: Spider closed (finished)
评论