[scrapy] spider object has no attribute '_rules'
这是因为__init__方法没有继承父类
解决办法:
# -*- coding:utf-8 -*-
from selenium import webdriver
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors import LinkExtractor
from sina_comment.items import SinaCommentItem
import re class MySpider(CrawlSpider): name = "sina"
#设置下载延时
download_delay = 2
allowed_domains = ['ent.sina.com.cn']
#第一篇文章地址
start_urls = ['http://ent.sina.com.cn/'] rules = [
Rule(LinkExtractor(allow=('http://ent.sina.com.cn/.*shtml')), callback='parse_item'),
]
def __init__(self,*args, **kwargs):
super(MySpider, self).__init__(*args, **kwargs) # 这里是关键
self.driver = webdriver.Chrome()
def parse_item(self, response):
self.log('Hi, this is an article page! %s' % response.url)
try:
self.driver
[scrapy] spider object has no attribute '_rules'的更多相关文章
- Scrapy Crawl 运行出错 AttributeError: 'xxxSpider' object has no attribute '_rules' 的问题解决
按照官方的文档写的demo,只是多了个init函数,最终执行时提示没有_rules这个属性的错误日志如下: ...... File "C:\ProgramData\Anaconda3\lib ...
- Scrapy 'module' object has no attribute 'Spider'错误
在“Scrapy入门教程”中,在创建的“dmoz_spider.py”文件中是通过 import scrapy class DmozSpider(scrapy.Spider): 的方式导入.但是用这种 ...
- scrapy spider官方文档
Spiders Spider类定义了如何爬取某个(或某些)网站.包括了爬取的动作(例如:是否跟进链接)以及如何从网页的内容中提取结构化数据(爬取item). 换句话说,Spider就是您定义爬取的动作 ...
- TypeError: 'Item' object has no attribute '__getitem__'
Error Msg: Traceback (most recent call last): File "start.py", line 8, in <module> E ...
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
- AttributeError: 'list' object has no attribute 'write_pdf'
我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...
- AttributeError: '_csv.reader' object has no attribute 'next'
我在使用pyhon3.4运行以下代码时报错:AttributeError: '_csv.reader' object has no attribute 'next' import csv import ...
- attributeError:'module' object has no attribute ** 解决办法
写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...
- AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
/*************************************************************************** * AttributeError: 'modu ...
随机推荐
- 算法(12)Pascal's Triangle II
题目:输出帕斯卡三角的第k行 思路:真没思路,发现几个easy的题不容易想!这里的大致思路是从后开始更新第k行!
- enter & keypress
enter & keypress https://stackoverflow.com/questions/905222/enter-key-press-event-in-javascript ...
- [Java] Java常见错误
1.处理java错误"编码 GBK 的不可映射字符" (1)首先记事本打开java源文件 (2)然后另存为,选择ANSI编码 (3)覆盖 (4)再试一下,ok,编译通过.
- typescript 贪吃蛇[学习过程中,模仿的一个例子]
代码实现ts: 1 'use strict' module Main { const FloorType = { space: "space", snack: "body ...
- Java23个设计模式的简明教程
设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了可重用代码.让代码更容易被他人理解.保证代码可靠性. 毫无疑问,设计模式于 ...
- luogu P2764 最小路径覆盖问题
题目描述 给定有向图G=(V,E).设P 是G 的一个简单路(顶点不相交)的集合.如果V 中每个顶点恰好在P 的一条路上,则称P是G 的一个路径覆盖.P 中路径可以从V 的任何一个顶点开始,长度也是任 ...
- [国家集训队]Crash的数字表格 / JZPTAB 莫比乌斯反演
---题面--- 题解: $$ans = \sum_{i = 1}^{n}\sum_{j = 1}^{m}{\frac{ij}{gcd(i, j)}}$$ 改成枚举d(设n < m) $$ans ...
- 洛谷 P1415 拆分数列 解题报告
拆分数列 题目背景 [为了响应党中央勤节俭.反铺张的精神,题目背景描述故事部分略去^-^] 题目描述 给出一列数字,需要你添加任意多个逗号将其拆成若干个严格递增的数. 如果有多组解,则输出使得最后一个 ...
- 【模拟赛·polyline】
Input file: polyline.in Output file: polyline.out Time limit: 1s Memory limit: 128M 有若⼲个类似于下⾯的函数: 定义 ...
- 常见编程语言对REPL支持情况小结
最近跟一个朋友聊起编程语言的一些特性,他有个言论让我略有所思:“不能REPL的都是渣”.当然这个观点有点偏激,但我们可以探究一下,我们常用的编程语言里面,哪些支持REPL,哪些不支持,还有REPL的一 ...