如何执行Scrapy类以及如何将其他方法添加到蜘蛛类中?在Scrapy类中定义其他方法
例如,从文档:
import scrapy
class DmozSpider(scrapy.Spider):
name = "dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"http://www.dmoz.org/Computers/Programming/Languages/Python/Books/",
"http://www.dmoz.org/Computers/Programming/Languages/Python/Resources/"
]
def parse(self, response):
filename = response.url.split("/")[-2] + '.html'
with open(filename, 'wb') as f:
f.write(response.body)
如果我想定义查询数据库或其他什么东西的一些方法,我怎么可能去有关,为什么?
能否请您详细说明你要查询的数据库是什么?谢谢。 – alecxe
要抓取的网址,例如 – Adders