Skip to content

Instantly share code, notes, and snippets.

@martinwheeler
Forked from anonymous/OSRSGEDataFetch.js
Created April 17, 2017 12:24
Show Gist options
  • Save martinwheeler/e5424bc9e4883532ca99917a2fbfd21d to your computer and use it in GitHub Desktop.
Save martinwheeler/e5424bc9e4883532ca99917a2fbfd21d to your computer and use it in GitHub Desktop.
Simple script to fetch OSRS GE data from their wiki pages.
// Run on a OSRS GE wiki page such as: http://2007.runescape.wikia.com/wiki/Exchange:Abyssal_whip
var prices = jQuery('[data-data]').attr('data-data').split('|'), thisprice, data = [], volumes = [], isSmall = false;
// This loop has been 'borrowed' from their implementation of Highcharts.
// http://2007.runescape.wikia.com/index.php?title=MediaWiki:Common.js/GECharts.js&action=raw&ctype=text/javascript&reviewed=1487971769
for (var i = 0; i < prices.length; i++ ) {
if ( prices[i].trim() ) {
thisprice = prices[i].split( ':' );
data.push( {
// time
time: new Date(parseInt( thisprice[0], 10 ) * 1000),
// @todo should this be parseInt?
// price
price: parseFloat( thisprice[1], 10 )
} );
if ( thisprice[2] && !isSmall ) {
volumes.push( [
// time
parseInt( thisprice[0], 10 ) * 1000,
// volume
// volumes are in millions
parseFloat( thisprice[2], 10 ) * 1000000
] );
}
}
}
console.log(data);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment