这是因为__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'的更多相关文章

  1. Scrapy Crawl 运行出错 AttributeError: 'xxxSpider' object has no attribute '_rules' 的问题解决

    按照官方的文档写的demo,只是多了个init函数,最终执行时提示没有_rules这个属性的错误日志如下: ...... File "C:\ProgramData\Anaconda3\lib ...

  2. Scrapy 'module' object has no attribute 'Spider'错误

    在“Scrapy入门教程”中,在创建的“dmoz_spider.py”文件中是通过 import scrapy class DmozSpider(scrapy.Spider): 的方式导入.但是用这种 ...

  3. scrapy spider官方文档

    Spiders Spider类定义了如何爬取某个(或某些)网站.包括了爬取的动作(例如:是否跟进链接)以及如何从网页的内容中提取结构化数据(爬取item). 换句话说,Spider就是您定义爬取的动作 ...

  4. TypeError: 'Item' object has no attribute '__getitem__'

    Error Msg: Traceback (most recent call last): File "start.py", line 8, in <module> E ...

  5. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  6. AttributeError: 'list' object has no attribute 'write_pdf'

    我在可视化决策树,运行以下代码时报错:AttributeError: 'list' object has no attribute 'write_pdf' 我使用的是python3.4 from sk ...

  7. AttributeError: '_csv.reader' object has no attribute 'next'

    我在使用pyhon3.4运行以下代码时报错:AttributeError: '_csv.reader' object has no attribute 'next' import csv import ...

  8. attributeError:'module' object has no attribute ** 解决办法

    写了一个小脚本,执行的时候报错: Traceback (most recent call last): File "F:/test/qrcode.py", line 109, in ...

  9. AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

    /*************************************************************************** * AttributeError: 'modu ...

随机推荐

  1. Delphi中取得程序版本号

    Delphi做的程序,如果想包含版本信息, 必须在Delphi的集成编辑环境的菜单“Project/Options/Version Info”里面添加版本信息.即在Version Info 选项卡中选 ...

  2. elasticsearch集群及filebeat server和logstash server

    elasticsearch集群及filebeat server和logstash server author:JevonWei版权声明:原创作品blog:http://119.23.52.191/ 实 ...

  3. P3539 [POI2012]ROZ-Fibonacci Representation

    题目描述 The Fibonacci sequence is a sequence of integers, called Fibonacci numbers, defined as follows: ...

  4. 机器学习:最近邻规则KNN算法

    这个算法就比较简单易懂了 就是把每个向量的特征值抽象成坐标,寻找最近的k个点,来进行划分 代码如下 #include <iostream> #include <cstdio> ...

  5. C&C++——库头文件及其作用

    1. 一些头文件的作用::ANSI C.提供断言,assert(表达式):GCC.GTK,GNOME的基础库,提供很多有用的函数,如有数据结构操作函数.使用glib只需要包含:GCC.文件夹操作函数. ...

  6. 关于连通性问题的Tarjan算法暂结

    关于基础知识的预备桥和割点.双联通分量.强连通分量,支配树.(并不会支配树) 关于有向图的Tarjan,是在熟悉不过的了,它的主要功能就是求强联通分量,缩个点,但是要注意一下构建新图的时候有可能出现重 ...

  7. 【BZOJ 3165】 [Heoi2013]Segment 李超线段树

    所谓李超线段树就是解决此题一类的问题(线段覆盖查询点最大(小)),把原本计算几何的题目变成了简单的线段树,巧妙地结合了线段树的标记永久化与标记下传,在不考虑精度误差的影响下,打法应该是这样的. #in ...

  8. Codeforces Round #526 (Div. 2) A.B

    A. The Fair Nut and Elevator 题目链接:https://codeforces.com/contest/1084/problem/A 题意: 一栋房子有n层楼,同时有个电梯( ...

  9. POJ1733:Parity Game(离散化+带权并查集)

    Parity Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 12853   Accepted: 4957 题目链接 ...

  10. linux 监控网卡实时流量iftop

    一.安装iftop Centos也可以直接yum install iftop -y http://www.tcpdump.org/release/ 到如下获取libpcap.tcpdump iftop ...