Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* database */
- var db = openDatabase('data1', '1.0', 'url list', 100e6);
- db.transaction(function (tx) {
- // tx.executeSql('DROP TABLE IF EXISTS hdw');
- tx.executeSql('CREATE TABLE IF NOT EXISTS hdw (url text unique)');
- });
- for(var i=0;i<6800;i++) setTimeout(get_url,~~(i*100),"http://hdwallpapersfor.com/top/"+i*24+"/47817658c89f15d634d488fabe77d4e2/",action1);
- var j=0;
- function action1(){
- var s=this.toString();
- var a=s.match(/\/thumbnail-small\/\S+\.jpg/gim).map(function(v,i){return v.replace("/thumbnail-small/","http://hdwallpapersfor.com/wallpaper/")});;
- console.log(a.join("\n"),j++,a.length);
- // post_imgur(a,print1);
- /* insert database */
- db.transaction(function (tx) {
- a.forEach(function(v,i){ tx.executeSql('INSERT OR IGNORE INTO hdw (url) values(?)',[v])})
- });
- }
- function print1(){console.log("imgur: ", this.toString().split("\n").length-1)}
- /* upload imgur */
- function post_imgur(a,callback) {
- var r=new XMLHttpRequest();
- r.open("POST","http://176.34.162.148/jabry/imgur1.asp?u=&b=",true);
- //r.open("POST","http://notebook1.lan:8000/jabry/imgur1.asp?u=&b=",true);
- r.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- r.onreadystatechange=function(){if (this.readyState==4 && this.status==200) callback.call(this.responseText); }
- r.send("u=" + a.join(","));
- }
- /* fetch url */
- function get_url(url,callback) {
- var r=new XMLHttpRequest();
- r.open("GET",url,true);
- r.onreadystatechange=function(){
- if (this.readyState==4 && this.status==200) callback.call(this.responseText);
- }
- r.send();
- }
- function sub1(){
- var db = openDatabase("data1", "1.0", "url list", 1E8);
- db.transaction(function(tx) {
- var iSQL="SELECT count(*) from hdw";
- iSQL="select url from hdw where url like '%\car-%' limit 10";
- tx.executeSql(iSQL, [], grid1, onError)
- });
- function onError(e) {
- console.log(e)
- }
- function grid1(tx, results) {
- if(results.rows.length == 0) {
- console.log("No records found");
- return false
- }
- for(var i = 0;i < results.rows.length;i++) {
- console.log(results.rows.item(i).url);
- if(i > 100) {
- break
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement