首先安装依赖:
npm install faker
示例代码:
const faker = require('faker');
const fs = require('node:fs')
function generateRandomEmail(num){let str = ''for (let i = 0; i < num; i++) {str += faker.internet.email() + '&:focus:&';}fs.writeFileSync('email.txt',str,'utf-8',{ flag: 'a' })
}generateRandomEmail(99999)const faker = require('faker');
const fs = require('node:fs')
function generateRandomEmail(num){let str = ''for (let i = 0; i < num; i++) {str += faker.internet.email() + '&:focus:&';}fs.writeFileSync('email.txt',str,'utf-8',{ flag: 'a' })
}generateRandomEmail(99999)
效果展示: