Commit 445eac3f authored by nanahira's avatar nanahira

4 digit

parent bcfa12eb
Pipeline #11597 passed with stages
in 2 minutes and 44 seconds
...@@ -2,12 +2,16 @@ import axios from 'axios'; ...@@ -2,12 +2,16 @@ import axios from 'axios';
import fs from 'fs'; import fs from 'fs';
import _ from 'lodash'; import _ from 'lodash';
let current = parseInt(process.env.CURRENT) || 0; let current = parseInt(process.env.CURRENT || '0', 36);
let max = parseInt(process.env.MAX || 'ZZZZ', 36);
const parallel = parseInt(process.env.PARALLEL) || 10; const parallel = parseInt(process.env.PARALLEL) || 10;
const useCode = async (n: number) => { const useCode = async (n: number) => {
const code = n.toString(36).toUpperCase(); let code = n.toString(36).toUpperCase();
console.log(`Trying ${n} - ${code}`); if (code.length < 4) {
code = '0'.repeat(4 - code.length) + code;
}
console.log(`Trying ${code}`);
try { try {
const result = await axios.get(`http://www.clco.cc/${code}`, { const result = await axios.get(`http://www.clco.cc/${code}`, {
responseType: 'text', responseType: 'text',
...@@ -15,26 +19,26 @@ const useCode = async (n: number) => { ...@@ -15,26 +19,26 @@ const useCode = async (n: number) => {
timeout: parseInt(process.env.TIMEOUT) || 10000, timeout: parseInt(process.env.TIMEOUT) || 10000,
}); });
if (result.status === 404) { if (result.status === 404) {
console.log(`Bad ${n} - ${code}`); console.log(`Bad ${code}`);
} else { } else {
const data = { const data = {
status: result.status, status: result.status,
headers: result.headers, headers: result.headers,
data: result.data, data: result.data,
}; };
console.log(`Good ${n} - ${code}: ${JSON.stringify(data)}`); console.log(`Good ${code}: ${JSON.stringify(data)}`);
await fs.promises.writeFile( await fs.promises.writeFile(
`data/${n}-${code}.json`, `data/${n}-${code}.json`,
JSON.stringify(data, null, 2), JSON.stringify(data, null, 2),
); );
} }
} catch (e) { } catch (e) {
console.error(`Failed ${n} - ${code}: ${e.message}`); console.error(`Failed ${code}: ${e.message}`);
} }
}; };
async function main() { async function main() {
while (true) { while (current <= max) {
const start = current; const start = current;
const end = start + parallel; const end = start + parallel;
console.log(`Running ${start} - ${end - 1}`); console.log(`Running ${start} - ${end - 1}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment