输出结果
后期更新……
实现代码
import scrapy
class DmozSpider(scrapy.Spider):
name ="dmoz"
allowed_domains = ["dmoz.org"]
start_urls = [
"https://dmoztools.net/Computers/Programming/Languages/Python/Resources/"
"https://dmoztools.net/Computers/Programming/Languages/Python/Books/"
]
def parse(self,response):
filename = response.url.split("/")[-2]
with open(filename, 'wb') as f:
f.write(response.body)