有两个蜘蛛使用相同的资源文件和几乎相同的结构。
SpiderA 包含:
import scrapy
import pkgutil
class StockSpider(scrapy.Spider):
name = "spiderA"
data = pkgutil.get_data("tutorial", "resources/webs.txt")
data = data.decode()
urls = data.split("\r\n")
start_urls = [url + "string1" for url in urls]
def parse(self, response):
pass
SpiderB 包含:
import scrapy
import pkgutil
class StockSpider(scrapy.Spider):
name = "spiderB"
data = pkgutil.get_data("tutorial", "resources/webs.txt")
data = data.decode()
urls = data.split("\r\n")
start_urls = [url + "string2" for url in urls]
def parse(self, response):
pass
如何结合spiderA和spiderB,并添加一个开关变量来crapy scral根据我的需要调用不同的spider?
ITMISS
HUX布斯
相关分类