Skip to content

Instantly share code, notes, and snippets.

@majindageta
Created April 9, 2020 10:12
Show Gist options
  • Save majindageta/5ebfc3409cff4732bc70b57143288643 to your computer and use it in GitHub Desktop.
Save majindageta/5ebfc3409cff4732bc70b57143288643 to your computer and use it in GitHub Desktop.
import readline from 'readline'
import fs from 'fs'
fs.writeFileSync('./output.txt', '', {flag: 'w'})
const readInterface = readline.createInterface(
fs.createReadStream('./folder/list.html'),process.stdout
);
readInterface.on('line', function(line) {
// console.log(line);
let str: string = line;
if (str.includes('gameListRowItemName ellipsis')) {
let index: number = str.indexOf('">');
let endIndex: number = str.indexOf('</')
if (index > 0 && endIndex > 0) {
let pi = str.substring(index + 2, endIndex);
// console.log(pi);
fs.writeFileSync('./output.txt', pi + '\n', {flag: 'a'})
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment