Skip to content

boss

代码:

index.jsinit.jspackage.json处于同一文件夹内!!!

index.js

js

const fs = require('fs');
const docx = require('docx');

const { Document, Paragraph, TextRun, ExternalHyperlink } = docx;

const {jobList} = JSON.parse(fs.readFileSync('./job.json', { encoding: 'utf8'})).zpData
const externalHyperlinks = []
jobList.forEach(({jobName, encryptJobId}) => {
    const link = `https://www.zhipin.com/job_detail/${encryptJobId}.html`
    externalHyperlinks.push(new Paragraph({
        children: [
            new ExternalHyperlink({
                link: link,
                children: [
                    new TextRun({
                        text: jobName,
                        underline: true,
                        color: '0000FF',
                    }),
                ],
            })
        ]
    }))
})

const doc = new Document({
    sections: [
        {
            properties: {},
            children: externalHyperlinks
        },
    ],
});
docx.Packer.toBuffer(doc).then((buffer) => {
    // 将buffer写入到文件
    require('fs').writeFileSync("./job.docx", buffer)
})

init.js

js
const fs = require('fs');

fs.writeFileSync('./job.json', JSON.stringify({}), { encoding: 'utf8'})

package.json

json
{
  "name": "boss",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "docx": "^8.5.0"
  }
}

使用教程:

  1. 进入https://www.zhipin.com/web/geek/job
  2. 3752c091-b947-4542-9add-85177bb7f906.png
  3. ac1628a0-5cd0-4422-a691-730b0d27d4e1.png
  4. 0ca9e447-f900-4134-b810-e0749af3e024.png
  5. 打开存放代码的文件夹,然后794732f3-fd33-4079-ab5e-afd9262fcc75.png
  6. 执行init.js,命令:node init.js,执行完会产生一个job.json的文件
  7. 将刚从浏览器复制的内容粘贴到job.json
  8. 执行index.js,命令:node index.js,会产生一个job.docx文件,搞定
  9. 9b39fee4-54e7-4324-828b-fa5c171a9aa8.png
  10. 4149ec56-cb48-4a08-abb2-9b084f676924.png
  11. 跳到第7步

最近更新:6/6/2024, 10:33:05 PM

原文链接:boss

下一篇:idea插件