关于scrapy问题
这是items.py代码import scrapy
class CeshiItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
prince = scrapy.Field()
bookname = scrapy.Field()
这是我的spider.py代码
# -*- coding: utf-8 -*-
import scrapy
from ceshi.items import CeshiItem
class BookSpider(scrapy.Spider):
name = 'book'
allowed_domains = ['https://market.douban.com/']
start_urls = ['https://market.douban.com/book/?utm_campaign=book_freyr_section&utm_source=douban&utm_medium=pc_web&page=1&page_num=18&']
def parse(self, response):
bookItem = []
item = CeshiItem(scrapy.Item)
booklist = response.xpath('//div[@class="panel-detail"]')
for each in booklist:
item['prince'] = each.xpath('./span[@class="book-price"]/i/text()').extracrt()
item['bookname'] = each.xpath('./div[@class="book-brief"]/h3/text()').extract()
bookItem.append(item)
return bookTtem
为啥我最后模拟得出来的是个空列表。哪里出问题了吗 有大神来帮助一下我吗 ??有人吗
数据匹配有问题吧,去调试看看
页:
[1]