daily pastebin goal
92%
SHARE
TWEET

Untitled

a guest Sep 23rd, 2016 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Request failed for http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=undefined returned
  2.    
  3. var address = 'ip';
  4. var user = 'user';
  5. var userPwd = 'pw';
  6. var db = 'db';
  7.  
  8. var dbUrl = 'jdbc:mysql://' + address + '/' + db;
  9.  
  10. function getJSON(id) {
  11.  
  12.   var url = "http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=" + id;
  13.   var response = UrlFetchApp.fetch(url); // get api endpoint
  14.   var json = response.getContentText(); // get the response content as text
  15.   var data = JSON.parse(json)
  16.  
  17.   var conn = Jdbc.getConnection(dbUrl, user, userPwd);
  18.  
  19.   var stmt = conn.prepareStatement('INSERT INTO items '
  20.       + '(name, description, itemid, img) values (?, ?, ?, ?)');
  21.   stmt.setString(1,data.item.name);
  22.   stmt.setString(2, data.item.description);
  23.   stmt.setString(3,data.item.id);
  24.   stmt.setString(4, data.item.icon);
  25.   stmt.execute();
  26. }
  27.  
  28. for(var i = 0; i < 50000; i++){
  29.   try{
  30.     Utilities.sleep(6000);
  31.     getJSON(i);
  32.   } catch(e) {
  33.     i++;
  34.   }
  35. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand