super_song666 2017-05-12 03:58 采纳率: 0%
浏览 7485

用anaconda的scrapy爬取数据,按照步骤设置好了,却爬不到数据,求助大神救救菜鸟

这是运行的全部结果:
(D:\Anaconda2) C:\Users\luyue>cd C:\Users\luyue\movie250

(D:\Anaconda2) C:\Users\luyue\movie250>scrapy crawl movie250 -o items.json
2017-05-12 19:24:26 [scrapy.utils.log] INFO: Scrapy 1.3.3 started (bot: movie250)
2017-05-12 19:24:26 [scrapy.utils.log] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'movie250.spiders', 'FEED_URI': 'items.json', 'SPIDER_MODULES': ['movie250.spiders'], 'BOT_NAME': 'movie250', 'ROBOTSTXT_OBEY': True, 'FEED_FORMAT': 'json'}
2017-05-12 19:24:26 [scrapy.middleware] INFO: Enabled extensions:
['scrapy.extensions.feedexport.FeedExporter',
'scrapy.extensions.logstats.LogStats',
'scrapy.extensions.telnet.TelnetConsole',
'scrapy.extensions.corestats.CoreStats']
2017-05-12 19:24:26 [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.stats.DownloaderStats']
2017-05-12 19:24:26 [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']
2017-05-12 19:24:26 [scrapy.middleware] INFO: Enabled item pipelines:
[]
2017-05-12 19:24:26 [scrapy.core.engine] INFO: Spider opened
2017-05-12 19:24:26 [scrapy.extensions.logstats] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
2017-05-12 19:24:26 [scrapy.extensions.telnet] DEBUG: Telnet console listening on 127.0.0.1:6023
2017-05-12 19:24:26 [scrapy.core.engine] DEBUG: Crawled (403) (referer: None)
2017-05-12 19:24:26 [scrapy.core.engine] DEBUG: Crawled (403) (referer: None)
2017-05-12 19:24:27 [scrapy.spidermiddlewares.httperror] INFO: Ignoring response : HTTP status code is not handled or not allowed
2017-05-12 19:24:27 [scrapy.core.engine] INFO: Closing spider (finished)
2017-05-12 19:24:27 [scrapy.statscollectors] INFO: Dumping Scrapy stats:
{'downloader/request_bytes': 445,
'downloader/request_count': 2,
'downloader/request_method_count/GET': 2,
'downloader/response_bytes': 496,
'downloader/response_count': 2,
'downloader/response_status_count/403': 2,
'finish_reason': 'finished',
'finish_time': datetime.datetime(2017, 5, 12, 11, 24, 27, 13000),
'log_count/DEBUG': 3,
'log_count/INFO': 8,
'response_received_count': 2,
'scheduler/dequeued': 1,
'scheduler/dequeued/memory': 1,
'scheduler/enqueued': 1,
'scheduler/enqueued/memory': 1,
'start_time': datetime.datetime(2017, 5, 12, 11, 24, 26, 675000)}
2017-05-12 19:24:27 [scrapy.core.engine] INFO: Spider closed (finished)

展开全部

  • 写回答

4条回答 默认 最新

  • super_song666 2017-05-12 03:56
    关注

    代码也是在网上找的现成的,不知道哪里出了问题,求指教;下面是爬虫的代码
    import scrapy
    from movie250.items import Movie250Item

    class Movie250Spider(scrapy.Spider):
    """docstring for Movie250Spider"""
    name = 'movie250'
    allowed_domains = ["douban.com"]
    start_urls = [
    "http://movie.douban.com/top250/"
    ]

    def parse(self, response):
    for info in response.xpath('//div[@class="item"]'):
    item = Movie250Item()
    item['rank'] = info.xpath('div[@class="pic"]/em/text()').extract()
    item['title'] = info.xpath('div[@class="pic"]/a/img/@alt').extract()
    item['link'] = info.xpath('div[@class="pic"]/a/@href').extract()
    item['star'] = info.xpath('div[@class="info"]/div[@class="bd"]/div[@class="star"]/span/em/text()').extract()
    item['rate'] = info.xpath('div[@class="info"]/div[@class="bd"]/div[@class="star"]/span/text()').extract()
    item['quote'] = info.xpath('div[@class="info"]/div[@class="bd"]/p[@class="quote"]/span/text()').extract()
    yield item

    # 翻页
    next_page = response.xpath('//span[@class="next"]/a/@href')
    if next_page:
      url = response.urljoin(next_page[0].extract())
      yield scrapy.Request(url, self.parse)
    
    评论
  • Android丶龙 2017-05-12 04:32
    关注
    评论
  • a华丽的冒险 2017-10-16 05:43
    关注

    同问,我跟着MOOC上打完代码,运行后发现得到的空文本,也没爬到数据。。T^T

    评论
  • 逸少凌仙 2019-07-30 15:52
    关注

    settings.py里面的ITEM_PIPELINES没有打开。。。。

    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 okhttp分片上传文件,到最后一个分片提示:Invalid Content-Length
  • ¥15 有关汽车的MC9S12XS128单片机实验
  • ¥15 求c语言动态链表相关课程有偿,或能将这块知识点讲明白
  • ¥15 FLKT界面刷新异常
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥50 单细胞测序拟时序分析
  • ¥50 运行springboot项目报错
  • ¥15 FTP 站点对站点传输失败
  • ¥15 宝塔面板一键迁移使用不了
  • ¥15 求一个按键录像存储到内存卡的ESP32CAM代码
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部