2 回复
不知道行不行,试试吧
exports.main = async (event, context) => {
var option = {
headers: {
'Accept': '*/*',
'Accept-Encoding': 'utf-8',
'Accept-Language': 'zh-CN,zh;q=0.8',
'Connection': 'keep-alive',
'user-agent': 'Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Mobile Safari/537.36',
}
};
return await new Promise((resolve, reject) => {
try {
https.get(event.url, option, (res) => {
var contont = '', location = res.headers.location
res.on('data', (chunk) => {
contont += chunk
});
res.on('end', () => {
resolve({location,contont})
});
}).on('error', (e) => {
reject(e)
});
} catch (e) {
reject(e)
}
})
}