zoudick97
zoudick97
采纳率100%
2016-03-06 01:42

scrapy 报错:Missing scheme in request url: h

40
已采纳

用Python的scrapy写了一个从网页下图片的爬虫,报错:Missing scheme in request url: h
去百度了也google了都说是相对地址不完整要搞成绝对地址,我用urljoin试了没用,直接用完整的图片地址也没有用。
求大神帮助。
[code=python]import scrapy
from imageSpider.items import ImagespiderItem

class image_Spider(scrapy.Spider):
name="imgSpider"
allowed_domains=["image.baidu.com"]
start_urls=["http://image.baidu.com/"]

def parse(self,response):
    oriList=response.xpath('//div[@class="img_pic_wrap_layer"]/img/@src').extract()
    for each in oriList:
        each=response.urljoin(each)
        item=ImagespiderItem()
        item['image_urls']=each
        yield item[/code]

[code=python]# -*- coding: utf-8 -*-

Define here the models for your scraped items

#

See documentation in:

http://doc.scrapy.org/en/latest/topics/items.html

import scrapy

class ImagespiderItem(scrapy.Item):
# define the fields for your item here like:
# name = scrapy.Field()
image_urls=scrapy.Field()
images=scrapy.Field()
[/code]

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

相关推荐