鱼C论坛

 找回密码
 立即注册
查看: 2313|回复: 1

关于scrapy 没有Books 和Resources文件

[复制链接]
发表于 2017-7-31 08:58:34 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
   和小甲鱼一样先定义了Item容器 然后 编写爬虫Spider 可是在cmd中爬取的时候 没有Books和Spider文件

这是Item:# -*- 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 DmozItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    title = scrapy.Field()
    link = scrapy.Field()
    desc = scrapy.Field()
   
这是Spider:
import scrapy


class Dmozspider(scrapy.Spider):
    name = "dmoz"
    allowed_domains = ["dmoz.org"]
    start_urls = [
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
        "http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
        ]

    def parse(self,response):
        filename = response.url.split("/")[-2]
        with open(filename,'wb')as f:
            f.write(response.body)
        
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2017-8-24 17:33:49 | 显示全部楼层
1.关于为什么没有Books 和Resources文件 ,小甲鱼的回答是:根目录下没有存放 robots.txt 自然就是 404 咯;http://bbs.fishc.com/thread-91237-1-1.html
2.小甲鱼视频中所用的网址目前已经关闭了,你需要换其他网址才可以

绿色框中网址关闭了

绿色框中网址关闭了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-2-24 00:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表