// 云函数入口文件const cloud = require('wx-server-sdk')cloud.init()const rp = require('request-promise')const cheerio = require('cheerio')// 云函数入口函数exports.main = async(event, context) => { const news_html = await rp('http://news.gdut.edu.cn/ArticleList.aspx?category=4').then((res) => { return res }) const $ = cheerio.load(news_html) const news_title = $('.evenrow a') console.log(news_title) return 666} |
为什么本地没问题,云函数就报错?
关于上传并部署:云端安装依赖,上传所有文件两种方式都试过了。
请问问题出来哪里?
补充:我rp访问的网址应该提供cookie的但是我没有提供,所以获取不到我想要的html,但是我刚刚测试其他正常的网页也是报同样的错误!!!

国外论坛Stack Overflow有答案,我记得好像是要把cookie转化为字符串就可以了。
xxx.toString()
楼主,我的报错是cannot find module 'cheerio',你解决了吗?