Scrapy- Airbnb抓取,代码运行但不返回任何数据

时间:2019-12-11 20:34:40

标签: python web-scraping scrapy

以下代码运行,但是我无法从中获取任何数据。我正在尝试抓取the Airbnb website,我猜想我在'logements'变量上做错了什么,我是随机选择标签的,但仍然不知道它在哪里弄乱了。我在另一个网站上使用了此代码,并且可以正常工作,所以我非常感谢您的帮助。

import scrapy


class BarceloneSpider(scrapy.Spider):
    name = 'barcelone'
    start_urls = ['https://www.airbnb.fr/s/Barcelone--Espagne/homes?checkin=2https://www.airbnb.fr/s/Barcelone--Espagne/homes?refinement_paths%5B%5D=%2Fhomes&current_tab_id=home_tab&selected_tab_id=home_tab&place_id=ChIJ5TCOcRaYpBIRCmZHTz37sEQ&search_type=pagination&screen_size=medium&hide_dates_and_guests_filters=false&checkin=2020-01-24&checkout=2020-01-27&adults=2&s_tag=Kc7JRtKj&section_offset=5&items_offset=18&last_search_session_id=4b5ab129-f6dd-45ff-91e0-5c6bf9591c25']

    def parse(self, response):
        data={}
        logements= response.css('div.FMP-target')

        for logement in logements:
            for l in logement.css('span._1llb8an::text'):
                data['price']= l.getall()
                yield data

输出:

2019-12-11 21:16:37 [scrapy.utils.log] INFO: Scrapy 1.8.0 started (bot: barcelone_airbnb)
2019-12-11 21:16:37 [scrapy.utils.log] INFO: Versions: lxml 4.4.2.0, libxml2 2.9.5, cssselect 1.1.0, parsel 1.5.2, w3lib 1.21.0, Twisted 19.10.0, Python 3.7.4 (default, Aug  9 2019, 18:34:13) [MSC v.1915 64 bit (AMD64)], pyOpenSSL 19.1.0 (OpenSSL 1.1.1d  10 Sep 2019), cryptography 2.8, Platform Windows-10-10.0.18362-SP0
2019-12-11 21:16:37 [scrapy.crawler] INFO: Overridden settings: {'BOT_NAME': 'barcelone_airbnb', 'FEED_FORMAT': 'csv', 'FEED_URI': 'barc.csv', 'NEWSPIDER_MODULE': 'barcelone_airbnb.spiders', 'ROBOTSTXT_OBEY': True, 'SPIDER_MODULES': ['barcelone_airbnb.spiders']}
2019-12-11 21:16:37 [scrapy.extensions.telnet] INFO: Telnet Password: 84bc072ef7202063
2019-12-11 21:16:37 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.corestats.CoreStats',
 'scrapy.extensions.telnet.TelnetConsole',
 'scrapy.extensions.feedexport.FeedExporter',
 'scrapy.extensions.logstats.LogStats']
2019-12-11 21:16:37 [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']
2019-12-11 21:16:37 [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']
2019-12-11 21:16:37 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2019-12-11 21:16:37 [scrapy.core.engine] INFO: Spider opened
2019-12-11 21:16:37 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2019-12-11 21:16:37 [scrapy.extensions.telnet] INFO: Telnet console listening on 127.0.0.1:6023
2019-12-11 21:16:37 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.airbnb.fr/robots.txt> (referer: None)
2019-12-11 21:16:38 [scrapy.core.engine] DEBUG: Crawled (200) <GET https://www.airbnb.fr/s/Barcelone--Espagne/homes?checkin=2https://www.airbnb.fr/s/Barcelone--Espagne/homes?refinement_paths%5B%5D=%2Fhomes&current_tab_id=home_tab&selected_tab_id=home_tab&place_id=ChIJ5TCOcRaYpBIRCmZHTz37sEQ&search_type=pagination&screen_size=medium&hide_dates_and_guests_filters=false&checkin=2020-01-24&checkout=2020-01-27&adults=2&s_tag=Kc7JRtKj&section_offset=5&items_offset=18&last_search_session_id=4b5ab129-f6dd-45ff-91e0-5c6bf9591c25> (referer: None)
2019-12-11 21:16:38 [scrapy.core.engine] INFO: Closing spider (finished)
2019-12-11 21:16:38 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 911,
 'downloader/request_count': 2,
 'downloader/request_method_count/GET': 2,
 'downloader/response_bytes': 93128,
 'downloader/response_count': 2,
 'downloader/response_status_count/200': 2,
 'elapsed_time_seconds': 1.43874,
 'finish_reason': 'finished',
 'finish_time': datetime.datetime(2019, 12, 11, 20, 16, 38, 955887),
 'log_count/DEBUG': 2,
 'log_count/INFO': 10,
 'response_received_count': 2,
 'robotstxt/request_count': 1,
 'robotstxt/response_count': 1,
 'robotstxt/response_status_count/200': 1,
 'scheduler/dequeued': 1,
 'scheduler/dequeued/memory': 1,
 'scheduler/enqueued': 1,
 'scheduler/enqueued/memory': 1,
 'start_time': datetime.datetime(2019, 12, 11, 20, 16, 37, 517147)}
2019-12-11 21:16:38 [scrapy.core.engine] INFO: Spider closed (finished)

0 个答案:

没有答案