| | |
| | | text = /(.|\n)*<pre>((.|\n)*)<\/pre>(.|\n)*/g.exec(text)[2]; |
| | | fs.writeFileSync(filepath, text, 'utf-8'); |
| | | } |
| | | fs.writeFileSync(filepath + '.result.txt', cleanText(text), 'utf-8'); |
| | | try { |
| | | fs.writeFileSync(filepath + '.result.txt', cleanText(text), 'utf-8'); |
| | | } catch (e) { |
| | | reject(e); |
| | | try { |
| | | out.close(); |
| | | fs.unlink(filepath, (e) => console.error(e)); |
| | | } catch (e) { |
| | | console.error(e); |
| | | } |
| | | } |
| | | }, 1000); |
| | | resolve(true); |
| | | }); |
| | |
| | | main(); |
| | | } |
| | | |
| | | // const filepath = "D:\\projects\\book-crawler\\downloads\\10231261 978-1-331-76167-9.txt"; |
| | | // const text = fs.readFileSync(filepath, 'utf8'); |
| | | // fs.writeFileSync(filepath + '.result.txt', cleanText(text), 'utf-8'); |