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';
import fs from 'fs';
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 useCode = async (n: number) => {
const code = n.toString(36).toUpperCase();
console.log(`Trying ${n} - ${code}`);
let code = n.toString(36).toUpperCase();
if (code.length < 4) {
code = '0'.repeat(4 - code.length) + code;
}
console.log(`Trying ${code}`);
try {
const result = await axios.get(`http://www.clco.cc/${code}`, {
responseType: 'text',
......@@ -15,26 +19,26 @@ const useCode = async (n: number) => {
timeout: parseInt(process.env.TIMEOUT) || 10000,
});
if (result.status === 404) {
console.log(`Bad ${n} - ${code}`);
console.log(`Bad ${code}`);
} else {
const data = {
status: result.status,
headers: result.headers,
data: result.data,
};
console.log(`Good ${n} - ${code}: ${JSON.stringify(data)}`);
console.log(`Good ${code}: ${JSON.stringify(data)}`);
await fs.promises.writeFile(
`data/${n}-${code}.json`,
JSON.stringify(data, null, 2),
);
}
} catch (e) {
console.error(`Failed ${n} - ${code}: ${e.message}`);
console.error(`Failed ${code}: ${e.message}`);
}
};
async function main() {
while (true) {
while (current <= max) {
const start = current;
const end = start + parallel;
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