admintest166 发表于 2020-3-18 20:10:42

【第五版】【通用性妹子图爬取】用pyspider爬取妹子图之nvshens

本帖最后由 admintest166 于 2020-3-19 01:18 编辑

到此为此 基本上鱼C各位大佬出的爬取妹子图的网站 小弟我基本上都用pyspider爬取了一遍(有些网站失效了就没有爬{:10_282:} )

后期我要是还有发现新的继续写 后期会出 pyspider+requests的 因为有些同学可能才开始学习爬虫 没有接触到框架

为什么说事通用性呢 看过我之前的3个爬取妹子图的文章 可以看出来 基本上代码都是相同的只不过CSS选择上不一样 其他都是大同小异的

对~没错{:10_279:}我无意义中发现用Pyspider爬取的这4个网站的妹子图 基本上我的代码除了CSS选择不一样 其他都是一样的

所以我给出的结论就是用pyspider 基本上可以显示只写一次 就可以爬取市面上很多妹子图网站 (除了CSS选择和网址要改哈{:10_256:} )

友情提示:python3.7以后包括3.7 运行pyspider会有很多BUG 如果不爱折腾 请把py版本降为python3.6就行日常开发3.6肯定够用了的

第一版:https://fishc.com.cn/thread-159925-1-1.html

第二版:https://fishc.com.cn/forum.php?mod=viewthread&tid=160363&highlight=pyspider

第三版:https://fishc.com.cn/forum.php?mod=viewthread&tid=160394&highlight=pyspider

第四版:https://fishc.com.cn/forum.php?mod=viewthread&tid=160749&highlight=pyspider(这是爬取小说的)

补充:妹子图那个网站基本上被我爬完了 10个G{:10_258:} {:10_279:}

{:10_256:} {:10_256:} {:10_256:}

之前的战果{:10_254:} {:10_256:}

#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Created on 2020-03-18 17:14:55
# Project: meinv

from pyspider.libs.base_handler import *


class Handler(BaseHandler):
    crawl_config = {
    }

    @every(minutes=24 * 60)
    def on_start(self):
      self.crawl('https://www.nvshens.net/gallery/', callback=self.index_page,validate_cert=False)

    @config(age=10 * 24 * 60 * 60)
    def index_page(self, response):
      for each in response.doc('.galleryli_title > a').items():
            self.crawl(each.attr.href, callback=self.detail_page,validate_cert=False)
      next=response.doc('.pagesYY').find('a').eq(-1).attr.href
      self.crawl(next, callback=self.index_page,validate_cert=False)

    @config(priority=2)
    def detail_page(self, response):
      for each in response.doc('#hgallery > img').items():
            self.crawl(each.attr.src, callback=self.detail_page2,validate_cert=False)
      next_img=response.doc('.a1').eq(-1).attr.href
      self.crawl(next_img, callback=self.detail_page,validate_cert=False)
   
    @config(priority=2)      
    def detail_page2(self, response):
      with open(('/root/meizi/{}'.format(response.url[-8:])),'wb') as f:
            f.write(response.content)
      return 'OK'
      

admintest166 发表于 2020-3-19 01:56:14

{:10_280:}{:10_280:}{:10_280:}

admintest166 发表于 2020-3-19 12:13:11

{:10_266:}{:10_266:}{:10_266:}

iufhwiuf 发表于 2020-3-23 15:29:25

页: [1]
查看完整版本: 【第五版】【通用性妹子图爬取】用pyspider爬取妹子图之nvshens