how to call a class"s function in a class, for example, I wrote
class DailishiyanDownloaderMiddleware (object):
-sharp Not all methods need to be defined. If a method is not defined,
-sharp scrapy acts as if the downloader middleware does not modify the
-sharp passed objects.
def canshu(self):-sharp
aa=["192.168.1.2","11.22.33","44,55,66"]
return aa
b=canshu(1)
print("",b)
def order(self):-sharp
print("order")
for i in range(10):
yield i
a=order(1)
@classmethod
def from_crawler(cls, crawler):
-sharp This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
........
will output normally, but if I write it this way, I will get an error AttributeError: "int" object has no attribute" canshu"
class DailishiyanDownloaderMiddleware (object):
-sharp Not all methods need to be defined. If a method is not defined,
-sharp scrapy acts as if the downloader middleware does not modify the
-sharp passed objects.
def canshu(self):-sharp
aa=["192.168.1.2","11.22.33","44,55,66"]
return aa
b=canshu(1)
-sharpprint("",b)
def order(self):-sharpSs
print("order",self.canshu())
for i in range(10):
yield i
a=order(1)
@classmethod
def from_crawler(cls, crawler):
-sharp This method is used by Scrapy to create your spiders.
s = cls()
crawler.signals.connect(s.spider_opened, signal=signals.spider_opened)
return s
......
scrapy,
bug