mirror of
https://github.com/DoctorMcKay/node-steamcommunity.git
synced 2025-01-04 06:46:57 +08:00
Added getMarketApps
Returns an object in format of {appid: appName, ...}
This commit is contained in:
parent
f3d88d6b83
commit
21895a221c
25
classes/CMarket.js
Normal file
25
classes/CMarket.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
var SteamCommunity = require('../index.js');
|
||||||
|
var Cheerio = require('cheerio');
|
||||||
|
|
||||||
|
SteamCommunity.prototype.getMarketApps = function(callback) {
|
||||||
|
var self = this;
|
||||||
|
this.request('https://steamcommunity.com/market/', function (err, response, body) {
|
||||||
|
if(self._checkHttpError(err, response, callback)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var $ = Cheerio.load(body);
|
||||||
|
if ($('.market_search_game_button_group')) {
|
||||||
|
apps = {};
|
||||||
|
$('.market_search_game_button_group > a').each(function (i, element) {
|
||||||
|
var e = Cheerio.load(element);
|
||||||
|
var name = e('.game_button_game_name').text().trim();
|
||||||
|
var url = element.attribs.href;
|
||||||
|
var appid = url.substr(url.indexOf('=') + 1);
|
||||||
|
apps[appid] = name;
|
||||||
|
});
|
||||||
|
callback(apps);
|
||||||
|
} else {
|
||||||
|
callback(null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
1
index.js
1
index.js
@ -309,6 +309,7 @@ SteamCommunity.prototype._checkHttpError = function(err, response, callback) {
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
require('./classes/CMarket.js');
|
||||||
require('./classes/CMarketItem.js');
|
require('./classes/CMarketItem.js');
|
||||||
require('./classes/CMarketSearchResult.js');
|
require('./classes/CMarketSearchResult.js');
|
||||||
require('./classes/CSteamGroup.js');
|
require('./classes/CSteamGroup.js');
|
||||||
|
Loading…
Reference in New Issue
Block a user