微信小程序云开发实现抓包
**
微信小程序云开发实现抓包 **
需要插件
const cheerio = require("cheerio");
const request = require('superagent');
const Promise = require('bluebird');
实现代码
//豆瓣排行榜
async function getDoubanHot() {
let page = await getPage('https://movie.douban.com/chart/');
let $ = cheerio.load(page.text);
let random = Math.ceil(Math.random() * 10)
let title = $(".indent").find('.item').find('.nbg')[random].attribs.title
let image = $(".indent").find('.item').find('.nbg').find('img')[random].attribs.src
let desc = $(".indent").find('.item').find('.pl2').find('p[class="pl"]')[random].children[0].data
let rating_nums = $(".indent").find('.item').find('.rating_nums')[random].children[0].data
let pl = $(".indent").find('.item').find('.star.clearfix').find('.pl')[random].children[0].data
let t = desc.substring(0, 4);
let time = new Date().getFullYear;
if (time - Number(t) <= 0) {
t = 0;
}
return {
year: t,
average: 1,
title,
rating_nums,
pl,
desc,
image
}
}
let dlist = [];
try {
let page = await getPage(pppUrl + '/index.php?m=vod-search&wd=' + encodeURI(event.name));
let $ = cheerio.load(page.text);
getSearchResult($, dlist)
let numberString = $('.row').find("div[class='hy-video-head']").find('h4[class="margin-0"]').find('span[class="text-color"]').text().split('”“')[1].replace("”", "")
let number = Number(numberString);
let count = Math.round(number / 10)
if (count > 10) {
count = 10
}
for (let i = 2;
i <= count;
i++) {
await sleep(50);
let page1 = await getPage(pppUrl + '/vod-search-pg-' + i + '-wd-' + encodeURI(event.name) + '.html');
let $1 = cheerio.load(page1.text);
getSearchResult($1, dlist)
}
} catch (err) {
//出错拉
} finally {
return JSON.stringify(dlist)
}
【微信小程序云开发实现抓包】具体项目请去github下载直通车
扫码去小程序查看
文章图片
推荐阅读
- 一个小故事,我的思考。
- 家乡的那条小河
- 一个人的碎碎念
- 野营记-第五章|野营记-第五章 讨伐梦魇兽
- 昨夜小楼听风
- 2021-02-17|2021-02-17 小儿按摩膻中穴-舒缓咳嗽
- 基于微信小程序带后端ssm接口小区物业管理平台设计
- 2019.4.18感恩日记
- 那件我们忽略的小事叫感恩
- 你有婚内虐待行为吗()