Skip to content

Instantly share code, notes, and snippets.

@ogawa0071
Created August 15, 2020 08:10
Show Gist options
  • Select an option

  • Save ogawa0071/5879559d26ccc95f400993d27950d6d5 to your computer and use it in GitHub Desktop.

Select an option

Save ogawa0071/5879559d26ccc95f400993d27950d6d5 to your computer and use it in GitHub Desktop.
psp-games-list
import axios from "axios";
import * as fs from "fs";
const startIndex = 0;
(async () => {
// 0 Start
const index = 0;
// 1 Start
const size = 100;
loop(size, index);
})();
async function loop(size: number, index: number) {
console.log(`Start: ${index}`);
const res = await axios(
`https://store.playstation.com/valkyrie-api/ja/JP/999/container/PN.CH.JP-PN.CH.MIXED.JP-GAMESALL?sort=release_date&direction=desc&platform=psp&game_content_type=games&size=${size}&bucket=games&start=${index}`
);
for (const game of res.data.included) {
fs.promises.appendFile("games.json", `${JSON.stringify(game)},\n`);
}
const nextIndex = index + size - 1;
const nextSize = size;
if (nextIndex < 800) {
loop(nextSize, nextIndex);
}
}
{
"dependencies": {
"axios": "^0.19.2"
},
"devDependencies": {
"@types/node": "^14.0.27"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment