在用nodejs仿写单页模板扒手的时候,使用axios下载的图片无法正常打开,所以换了一种方式,下载图片需要两种一种http 一种https,用来下载http和https地址下的图片。
import fs from 'fs'
var Stream = require('stre...
yekong
1个月前 (04-05) 93℃
0喜欢
设置编码
在用nodejs仿写单页模板扒手的时候,实现下载css文件的时候,css文件是乱码的,排查发现可能是出现了bom头,设置一下写入编码就可以了。{encoding: 'utf8'}
fs.writeFile(filePaths, res.data, {encoding...
yekong
1个月前 (04-05) 101℃
0喜欢
const hash256Sync = createFileHash256Sync(filePath)
const hash256Syncafter = createFileHash256Sync(filePath2)
...
yekong
1个月前 (04-05) 83℃
0喜欢
在仿写单页模板扒手时,遇到一个需要删除文件的功能,以前也没用过fs,记录一下代码方便以后复用查询。
fs.unlink(filePath2,(err,data)=>{
if (err) {
...
yekong
1个月前 (04-05) 89℃
0喜欢
在用nodejs仿写单页模板扒手的时候,需要下载js文件,这里用到了axios以及fs来实现功能。
使用
async getDownJs() {
var that = this;
for (const url of that.jslist) {
...
yekong
1个月前 (04-04) 99℃
0喜欢
nodejs仿写单页模板扒手时,遇到下载文件却提示目录不存在,这就需要先判断一下目录是否存在,如果不存在就创建一个。使用到了fs.
fs判断目录是否存在不存在就创建
if (!fs.existsSync("/js/")) {
fs.mkdirSync(...
yekong
1个月前 (04-04) 91℃
0喜欢
初始化项目
mkdir egg-example && cd egg-example
npm init egg --type=simple
npm i
启动项目
npm run dev
open http://localhost:7001
...
yekong
4个月前 (01-19) 149℃
0喜欢
api
// 发送短信
smsApi.post('/sendSmsKsd', async ctx => {
console.log(ctx.request.body)
const tel = ctx.request.body.tel;
...
yekong
4个月前 (01-04) 169℃
0喜欢
打开package.json,找到scripts,在内部添加我们需要的命令就可以了
例如将babel src/index.js -o dist/index.js设置为npm命令,只需要将命令添加如下
"scripts": {
"build...
yekong
8个月前 (09-06) 391℃
0喜欢
安装依赖
babel-preset-es2015和babel-cli
cnpm i --save-dev babel-preset-es2015 babel-cli
项目根目录创建.babelrc
{
"presets": [
"es2...
yekong
8个月前 (09-06) 331℃
0喜欢