0
有我的Code.When我抓取其他網址時,這是沒有問題的,但是當我抓取此url.it問我列不匹配。我不知道爲什麼計數長度是字符長度,而不是字典長度?python scrapy xpath:InternalError:(1136,u「列計數與第1行的值計數不匹配」)
class JikespiderSpider(scrapy.Spider):
name = "jikespider"
allowed_domains = ["fromgeek.com"]
start_urls = ['http://www.fromgeek.com/topic/']
def parse(self, response):
sel = Selector(response)
jike_list = sel.xpath('//ul[@id="masonry0"]')
ll = len(sel.xpath('//ul[@id="masonry0"]/li'))
for jike in range(ll):
item = JikeItem()
try:
item['jike_title'] = jike_list.xpath('//li/div/div[@class="n-pic fl"]/a/@title').extract()[jike].strip()
item['jike_uptime'] = jike_list.xpath('//li/div/div[@class="n-keytime "]/div[@class="time fr"]/text()').extract()[jike].strip()
item['jike_tag'] = jike_list.xpath('//li/div/div[@class="n-keytime "]/div[@class="key fl"]').xpath('string(.)').extract()[jike].strip()
print len(item['jike_title'])
print len(item['jike_uptime'])
print len(item['jike_tag'])
print '--------------------------'
yield item
except Exception,e:
print e
請顯示您的'items.py',並且如果您將抓取的項目存儲到'db'中,然後'管道'代碼中,因爲項目被刮取,但是在處理獲取的項目期間發生問題。 – JkShaw