| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1266 人关注过本帖
标题:求助贴,python3中scrapy爬虫错误
只看楼主 加入收藏
HC__smile
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2019-5-8
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
求助贴,python3中scrapy爬虫错误
import scrapy
from douban_book.items import DoubanBookItem
 
 
class BookSpider(scrapy.Spider):
    """docstring for BookSpider"""
    name = 'douban-book'
    allowed_domain = ['']
    start_urls = ['https://book.']
 
    def parse(self, response):
        yield scrapy.Request(response.url, callback = self.parse_page)
 
        for page in response.xpath('//div[@class="paginator"]/a'):
            link = page.xpath('@href').extract()[0]
            yield scrapy.Request(link, callback = self.parse_page)
 
    def parse_page(self, response):
        for item in response.xpath('//tr[@class="item"]'):
            book = DoubanBookItem()
            book['name'] = item.xpath('td[2]/div[1]/a/@title').extract()[0]
            book['ratings'] =item.xpath('td[2]/div[2]/span[@class="rating_nums"]/text()').extract()[0]
            # book['ratings'] = item.xpath('td[2]/div[2]/span[2]/text()').extract()[0]
            book_info = item.xpath('td[2]/p[1]/text()').extract()[0]
            book_info_contents = book_info.strip().split(' / ')
            book['author'] = book_info_contents[0]
            book['publisher'] = book_info_contents[1]
            book['edition_year'] = book_info_contents[2]
            book['price'] = book_info_contents[3]
            yield book
错误:C:\anacoda\python.exe D:/scrapy/douban_book/douban_book/spiders/bookspider.py.py
Traceback (most recent call last):
  File "D:/scrapy/douban_book/douban_book/spiders/bookspider.py.py", line 6, in <module>
    from douban_book.items import DoubanBookItem
ModuleNotFoundError: No module named 'douban_book'
这是什么错误呀,谢谢!
搜索更多相关主题的帖子: 错误 item class response div 
2019-05-08 17:15
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:20 
没有douban_book这个模块,多清晰的提示啊

DO IT YOURSELF !
2019-05-09 07:47
快速回复:求助贴,python3中scrapy爬虫错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.237073 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved