Jump to content

getting G.E. prices with Google Spreadsheets


Recommended Posts

Posted

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 :)

Posted (edited)

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
Posted

 

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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