Python网络编程(第3版)官方pdf原版(中文)下载
import scrapy
class kandian(scrapy.Spider):
name = 'kandian'
def start_requests(self):
urls = [
'http://kandian.youth.cn/index/detail?sign=jG7lmryP69yBbN6',
'http://kandian.youth.cn/index/detail?sign=LgQZ4WplQxgDqPr',
]
for url in urls:
yield scrapy.http.Request(url=url,callback=self.parse)
def parse(self, response):
page = response.url.split('=')[-1]
filename = 'kandian-%s.html' % page
with open(filename,'wb+') as f:
f.write(response.body)
#self.log('Saved file %s' & filename)
转载请注明:谷谷点程序 » 一个scarpy简易的spider爬虫蜘蛛