Scrapy:Python实现scrapy框架爬虫两个网址下载网页内容信息——Jason niu
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)
不念过去,不畏将来!
理想,信仰,使命感……
愿你出走半生,归来仍是少年……

浙公网安备 33010602011771号