Deathpixel Posted September 24, 2015 Share Posted September 24, 2015 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. it has a table but no link i could copy paste in if i go to the iron ore itself 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 Quote Link to comment Share on other sites More sharing options...
Flamezzz Posted September 24, 2015 Share Posted September 24, 2015 (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 rs3https://medium.com/@paulgambill/how-to-import-json-data-into-google-spreadsheets-in-less-than-5-minutes-a3fede1a014aEDIT: 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 September 24, 2015 by Flamezzz Quote Link to comment Share on other sites More sharing options...
Deathpixel Posted September 24, 2015 Author Share Posted September 24, 2015 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! 1 Quote Link to comment Share on other sites More sharing options...