Skip to content

Commit

Permalink
Scrape type of vr support (#22)
Browse files Browse the repository at this point in the history
KevinNovak authored Dec 9, 2019
1 parent 92ea845 commit 3fe8108
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions public/scripts/index.js
Original file line number Diff line number Diff line change
@@ -181,12 +181,14 @@ async function retrieveSteamSearchTable() {
let appData = await post("./api/search-app-scrape", content);
app.headsets = appData.headsets || [];
app.countdown = appData.countdown || { text: "", time: 0 };
app.vrSupport = appData.vrSupport || "";
} else {
app.headsets = [];
app.countdown = {
text: "",
time: 0
};
app.vrSupport = "";
}
}

@@ -232,6 +234,7 @@ function getFormattedTime() {
function formatAppData(app) {
let formattedData = {
type: "",
vrSupport: "",
platform: "",
platformAbbreviated: "",
title: "",
@@ -247,6 +250,7 @@ function formatAppData(app) {
};

formattedData.type = app.type;
formattedData.vrSupport = app.vrSupport;
formattedData.platform = app.headsets.join(", ");
formattedData.platformAbbreviated = app.headsets
.map(platform => getHeadsetAbbreviation(platform))
18 changes: 18 additions & 0 deletions services/steam-scraper.js
Original file line number Diff line number Diff line change
@@ -16,13 +16,15 @@ function getAppPageData(appPageHtml) {

let gameData = getGameDataFromGameElement(firstGame);
let countdown = getCountdownFromGameElement(firstGame);
let vrSupport = getVrSupportFromGameElement(firstGame);
let headsets = getHeadsets(appPageHtml);
let reviews = getReviews(appPageHtml);

return {
...gameData,
...reviews,
countdown,
vrSupport,
headsets
};
}
@@ -54,10 +56,12 @@ function getSearchAppPageData(appPageHtml) {
}

let countdown = getCountdownFromGameElement(firstGame);
let vrSupport = getVrSupportFromGameElement(firstGame);
let headsets = getHeadsets(appPageHtml);

return {
countdown,
vrSupport,
headsets
};
}
@@ -307,6 +311,20 @@ function getCountdownFromGameElement(gameElement) {
return countdownData;
}

function getVrSupportFromGameElement(gameElement) {
let $ = _cheerio.load(gameElement);

let vrSupport = "NONE";

if ($(".vr_required").length > 0) {
vrSupport = "REQUIRED";
} else if ($(".vr_supported").length > 0) {
vrSupport = "SUPPORTED";
}

return vrSupport;
}

module.exports = {
getAppPageData,
getSearchAppPageData,

0 comments on commit 3fe8108

Please sign in to comment.