Jump to content

getting G.E. prices with Google Spreadsheets


Deathpixel

Recommended Posts

Hello people, i wanted to make a profit calc ETC with google spreadsheets but i have the hardest time making it grab the prices.

=Index(ImportHtml(Concatenate("http://services.runescape.com/m=itemdb_rs/results.ws?query=guam"), "table", 1),4,3)

did not work, though this should work for the RS3 G.E. but it does not

 

the only way i hoped i could get it to work was via the find table thing as in the link above but the Oldschool RS G.E. 

 

6ckxlAn.png

 

it has a table but no link i could copy paste in

 

if i go to the iron ore itself

 

TysAVjm.png

 

now it isn't in a table it can grab the price from all i could find is that the price is between <h3> and </h3>

 

http://services.runescape.com/m=itemdb_oldschool/Iron_ore/viewitem?obj=440

 

thought it was simple just grabbing a price from the G.E. with google spreadsheets... but nope

 

all help will be appreciated :)

Link to comment
Share on other sites

http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=3831

^ This is the OSRS ge API, there's also one for rs3


https://medium.com/@paulgambill/how-to-import-json-data-into-google-spreadsheets-in-less-than-5-minutes-a3fede1a014a


EDIT: doesn't seem to work quite well, so I wrote a custom function:
EDIT2: fixed comma issue

 

CELL FORMULA: =GetPriceRS3(<id>) or =GetPriceOSRS(<id>)




function GetPriceOSRS(id) {
  return GetPrice('http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=', id);
}

function getPriceRS3(id) {
 return GetPrice('http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=', id);
}

function GetPrice(url, id) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  var response = UrlFetchApp.fetch(url + id);
  var data = JSON.parse(response.getContentText());
  

  price = (''+data['item']['current']['price']).replace(/,/g, "");
  if(price[price.length-1] === 'b') price = price.substr(0,price.length-1)*1000000000;
  else if(price[price.length-1] === 'm') price = price.substr(0,price.length-1)*1000000;
  else if(price[price.length-1] === 'k') price = price.substr(0,price.length-1)*1000;
  
  return parseInt(price);  
}

Edited by Flamezzz
Link to comment
Share on other sites

 

http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=3831

^ This is the OSRS ge API, there's also one for rs3

https://medium.com/@paulgambill/how-to-import-json-data-into-google-spreadsheets-in-less-than-5-minutes-a3fede1a014a

EDIT: doesn't seem to work quite well, so I wrote a custom function:

 

CELL FORMULA: =GetPriceRS3(<id>) or =GetPriceOSRS(<id>)




function GetPriceOSRS(id) {
  return GetPrice('http://services.runescape.com/m=itemdb_oldschool/api/catalogue/detail.json?item=', id);
}

function getPriceRS3(id) {
 return GetPrice('http://services.runescape.com/m=itemdb_rs/api/catalogue/detail.json?item=', id);
}

function GetPrice(url, id) {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  var response = UrlFetchApp.fetch(url + id);
  var data = JSON.parse(response.getContentText());
  

  price = data['item']['current']['price'];
  if(price[price.length-1] === 'b') price = price.substr(0,price.length-1)*1000000000;
  else if(price[price.length-1] === 'm') price = price.substr(0,price.length-1)*1000000;
  else if(price[price.length-1] === 'k') price = price.substr(0,price.length-1)*1000;
  
  return parseInt(price);  
}

 

got it working! thank you very much!

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...