爱意满满的作品展示区。
artandlol

新年 V2 头像拼图

  •  
  •   artandlol · Jan 1, 2017 · 9340 views
  •   The specified image does not exist
    This topic created in 3469 days ago, the information mentioned may be changed or developed.
    Supplement 1  ·  Jan 1, 2017

    献上javascript抓取头像代码,非程序员 轻点

    javascript: 
    var htmlURL = window.location.href;
    var baselink = htmlURL.match(/.*=/g);
    var toplink = "https://www.sunp.eu.org/recent?p=";
    var toplinkNaN  = "https://www.sunp.eu.org/recent?p=NaN";
    if ( baselink != toplink || htmlURL==toplinkNaN )
    {
    window.open("https://www.sunp.eu.org/recent?p=1");
    localStorage.setItem("message",'');
    }
    function getLastNumberStr(str)
    {
     var strs = str.replace(/.*=/g,'');
     return strs;
    }
    var i = getLastNumberStr(htmlURL);
    i++;
    self.location=toplink+i.toString();
    var singlereg= /(\/\/cdn\.v2ex\.co\/avatar).*(png)/g;
    var html = document.documentElement.innerHTML;
    var htmlele = html.match(singlereg).toString().replace(/normal/g,"large").replace(/\,/g," ").replace(/\/\//g,"https://").replace(/png/g,"png\n");
    var localdata=localStorage.getItem("message");
    htmlele += localdata;
    localStorage.setItem("message",htmlele);
    console.log(htmlele);
    
    Supplement 2  ·  Jan 7, 2017

    代码更新 最后面的数值是v2总页面数。本人非程序员,轻拍。:)

    Array.prototype.uniquestr = function() {
    	var res = [];
    	var json = {};
    	for (var i = 0; i < this.length; i++) {
    		if (!json[this[i]]) {
    			res.push(this[i]);
    			json[this[i]] = 1;
    		}
    	}
    	return res;
    }
    var Urls = function(startUrl) {
    		this.startUrl = startUrl;
    		this.page = 0;
    		this.homePage = '';
    		this.heartsRecv = '';
    	}
    Urls.prototype.crawl = function(titles) {
    	var self = this;
    	var url = self.startUrl + titles;
    	titles--;
    	var singlereg = /(\/\/cdn\.v2ex\.co\/avatar).*(png)/g;
    	$.get(url, function(data, status) {
    		self.homePage = data;
    		if (titles != undefined) {
    			self.heartsRecv += data;
    		}
    		setTimeout(function() {
    			if (titles > 0) {
    				self.crawl(titles);
    			} else {
    				self.heartsRecv = self.heartsRecv.match(singlereg).uniquestr().toString().replace(/normal/g, "large").replace(/\,/g, " ").replace(/\/\//g, "https://").replace(/png/g, "png\n");
    				console.log(self.heartsRecv);
    				return false;
    			}
    		}, 1000);
    	});
    }
    new Urls('https://www.sunp.eu.org/recent?p=').crawl(10000);
    
    102 replies    2017-01-04 09:22:01 +08:00
    1  2  
    itfanr
        101
    itfanr  
       Jan 3, 2017
    @artandlol 额 好复杂
    KanVivii
        102
    KanVivii  
       Jan 4, 2017 via iPhone
    没有自己 伤心
    1  2  
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5688 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 03:30 · PVG 11:30 · LAX 20:30 · JFK 23:30
    ♥ Do have faith in what you're doing.