Advertisement
rg443

fetch_500px - 500px to imgur

Feb 10th, 2013
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 500px post to imgur
  2. function get_url(url,callback) {
  3.         var r=new XMLHttpRequest();
  4.         r.open("GET",url,true);
  5.         //r.setRequestHeader("X-Requested-With", "XMLHttpRequest");
  6.         //r.setRequestHeader("Accept-Encoding", "gzip");
  7.         r.onreadystatechange=function(){
  8.        if (this.readyState==4 && this.status==200 && callback) callback.call(this.responseText);
  9.        }
  10.     r.send();      
  11.  
  12. }
  13.  
  14. function post_imgur(a,callback) {        
  15. var r=new XMLHttpRequest();
  16. r.open("POST","http://176.34.162.148/jabry/imgur1.asp?u=&b=",true);
  17. //r.open("POST","http://notebook1.lan:8000/jabry/imgur1.asp?u=&b=",true);
  18. r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  19. r.onreadystatechange=function(){if (this.readyState==4 && this.status==200) callback&&callback.call(this.responseText); }
  20. r.send("u=" + a.join(","));
  21. }
  22. //var tag="editors",pages=326;
  23.  
  24. //tag="rg443/favorites",pages=925;
  25.  
  26. function fetch_500px(tag,pages) {
  27. console.log(tag,pages);
  28. var stack=0,stack2=0;
  29. for (var i=1;i<=pages;i++) stack++&&get_url("http://500px.com/"+tag+"?page="+i,function(){
  30.    var a=this.toString().match(/http:\/\/pcdn.500px.net\/\d+\/\w{40}\//g);
  31.    if(a)a=a.map(function(v){return v+"4.jpg"});
  32.    console.log(--stack,a&&a.length);
  33.    stack2++
  34.    a&&post_imgur(a,function(){console.log("imgur:",--stack2,this.toString().split("\n").length-1);});
  35.    });
  36. };
  37.  
  38. fetch_500px("popular",10);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement