最新消息: 新版网站上线了!!!

一个scarpy简易的spider爬虫蜘蛛

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爬虫蜘蛛