NodeJs抓取页面内容

const cheerio = require('cheerio'); const request = require('request'); let url = 'https://btc.com/' request({ url: url, encoding: null }, function (error, response, body) { if (!error && response.statusCode == 200) { var buf = iconv.decode(body, 'gb2312');//获取内容进行转码 $ = cheerio.load(buf); var pps = $('body > d...

read more..

随机数

function getRandom(start, end, fixed = 0) { let differ = end - start let random = Math.random() return (start + differ * random).toFixed(fixed) } getRandom(1,5) 1<= num >=5

read more..

H5打电话发短信

<meta name="format-detection" content="telephone=yes"/> <a href="tel:13660007710">13660007710</a> <a href="sms:13660007710">13660007710</a>

read more..

保存图片文件,下载图片

function downloadIamge(imgsrc, name) { //下载图片地址和图片名 let image = new Image(); // 解决跨域 Canvas 污染问题 image.setAttribute("crossOrigin", "anonymous"); image.onload = function () { let canvas = document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; ...

read more..

赛邮云通信SUBMAIL

NodeJs发送短信 var request = require('request'); let post = function (url, postdata) { let options = { url: url, formData: postdata }; return new Promise(function (resolve, reject) { request.post(options, function (err, response, body) { if (err) { reject(err) } else { resolve(b...

read more..

根据元素宽度设定高度比例

要求:图片根据宽度设置高度。正方形 .shopimg { width: 100%; height: 0; padding-bottom: 100%; position: relative; } .shopimg-info { position: absolute; top:0; left: 0; bottom: 0; right: 0; } .shopimg img { width: 100%; height: 100%; }

read more..

Vue中可以选择文字高亮的插件

npm install –save vue-text-highlight import TextHighlight from ‘vue-text-highlight’; Vue.component(‘text-highlight’, TextHighlight); <text-highlight :queries="queries">{{ description }}</text-highlight> data() { return { queries: ['birds', 'scatt'],//需要高亮的文字 description: 'Tropical birds scattered as Drake veered the Jeep' }; } ...

read more..