当前位置:   article > 正文

微信小程序云开发实现抓包_云函数抓包

云函数抓包

**

微信小程序云开发实现抓包

**
需要插件

const cheerio = require("cheerio");
const request = require('superagent');
const Promise = require('bluebird');
  • 1
  • 2
  • 3

实现代码

//豆瓣排行榜
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
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  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)
  }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22

具体项目请去github下载直通车
扫码去小程序查看
扫码去小程序查看

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/570705
推荐阅读
相关标签
  

闽ICP备14008679号