Advertisement
rg443

hdwallpapersfor -> imgur

May 6th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* database */
  2. var db = openDatabase('data1', '1.0', 'url list', 100e6);
  3. db.transaction(function (tx) {
  4.     // tx.executeSql('DROP TABLE IF EXISTS hdw');
  5.     tx.executeSql('CREATE TABLE IF NOT EXISTS hdw (url text unique)');
  6.   });
  7.  
  8.  
  9. for(var i=0;i<6800;i++) setTimeout(get_url,~~(i*100),"http://hdwallpapersfor.com/top/"+i*24+"/47817658c89f15d634d488fabe77d4e2/",action1);
  10. var j=0;
  11. function action1(){
  12.    var s=this.toString();
  13.    var a=s.match(/\/thumbnail-small\/\S+\.jpg/gim).map(function(v,i){return v.replace("/thumbnail-small/","http://hdwallpapersfor.com/wallpaper/")});;
  14.    console.log(a.join("\n"),j++,a.length);
  15.    // post_imgur(a,print1);
  16.   /* insert database */
  17.   db.transaction(function (tx) {
  18.     a.forEach(function(v,i){ tx.executeSql('INSERT OR IGNORE INTO hdw (url) values(?)',[v])})
  19.   });
  20.  
  21.  
  22.    }
  23. function print1(){console.log("imgur: ", this.toString().split("\n").length-1)}
  24.  
  25.  
  26.  
  27. /* upload imgur */
  28. function post_imgur(a,callback) {    
  29. var r=new XMLHttpRequest();
  30. r.open("POST","http://176.34.162.148/jabry/imgur1.asp?u=&b=",true);
  31. //r.open("POST","http://notebook1.lan:8000/jabry/imgur1.asp?u=&b=",true);
  32. r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  33. r.onreadystatechange=function(){if (this.readyState==4 && this.status==200) callback.call(this.responseText); }
  34. r.send("u=" + a.join(","));
  35. }
  36.  
  37. /* fetch url */
  38. function get_url(url,callback) {
  39.     var r=new XMLHttpRequest();
  40.     r.open("GET",url,true);
  41.     r.onreadystatechange=function(){
  42.        if (this.readyState==4 && this.status==200) callback.call(this.responseText);
  43.        }
  44.     r.send();      
  45.  
  46. }
  47.  
  48.  
  49.  
  50.  
  51. function sub1(){
  52. var db = openDatabase("data1", "1.0", "url list", 1E8);
  53. db.transaction(function(tx) {
  54.   var iSQL="SELECT count(*) from hdw";
  55.   iSQL="select url from hdw where url like '%\car-%' limit 10";
  56.  
  57.  
  58.   tx.executeSql(iSQL, [], grid1, onError)
  59. });
  60. function onError(e) {
  61.   console.log(e)
  62. }
  63. function grid1(tx, results) {
  64.   if(results.rows.length == 0) {
  65.     console.log("No records found");
  66.     return false
  67.   }
  68.   for(var i = 0;i < results.rows.length;i++) {
  69.     console.log(results.rows.item(i).url);
  70.     if(i > 100) {
  71.       break
  72.     }
  73.   }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement