这是我的代码:
from scrapy import *
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
class lala(CrawlSpider):
name="lala"
start_url=["http://www.lala.net/"]
rule = [Rule(SgmlLinkExtractor(), follow=True, callback='self.parse')]
def __init__(self):
super(lala, self).__init__(self)
print "\nworking\n"
def parse(self,response):
print "\n\n Middle \n"
print "\nend\n"
问题是:
UNFORMATTABLE OBJECT WRITTEN TO LOG with fmt '[%(system)s] %(text)s\n', MESSAGE LOST
2013-04-09 13:48:25+0100 UNFORMATTABLE OBJECT WRITTEN TO LOG with fmt '[%(system)s] %(text)s\n', MESSAGE LOST
2013-04-09 13:48:25+0100 UNFORMATTABLE OBJECT WRITTEN TO LOG with fmt '[%(system)s] %(text)s\n', MESSAGE LOST
2013-04-09 13:48:25+0100 UNFORMATTABLE OBJECT WRITTEN TO LOG with fmt '[%(system)s] %(text)s\n', MESSAGE LOST
2013-04-09 13:48:25+0100 UNFORMATTABLE OBJECT WRITTEN TO LOG with fmt '[%(system)s] %(text)s\n', MESSAGE LOST
请注意,在这种情况下,两者都会end
被working
打印出来。
如果我删除了 init,则没有错误,但由于未打印中间 msg,因此未调用解析。