javascript - 如何检查网站显示的真假?
问题描述
javascript 是否可以检查网站说的是真还是假?它实际上是一个空白页面,并且取决于 url(代码会根据某些内容更改它)它只是说“真”或假。它还说在检查元素的源位中。
这是网站:https ://api.roblox.com/ownership/hasasset?userId=130948426&assetId=4672521661
if (username){
roblox.getIdFromUsername(username).then(id => {
var tokenID = `https://api.roblox.com/ownership/hasasset?userId=${id}&assetId=4672521661`
message.channel.send(new Discord.RichEmbed().setTitle("Checking Purchases..").setDescription(`${tokenID} Hold Tight! We are just checking if you purchased a class!`).setFooter("Getroles").setColor("#ff4757")).then(() => {
if(!(tokenID() === true)){
message.channel.send('You have bought it!');
}
用户名被拒绝。因此,当我执行命令时,它只发送嵌入而不发送其他任何内容。我很坚持这一点
解决方案
使用axios获取网页。
axios.get(tokenID).then(({data}) => {
console.log(data) // debug
const bought = data === 'true'
// ...send message to user
})
推荐阅读
- c# - List<...Model> 如何使用 Vue.js 实现?
- node.js - Socket.io 不适用于 ejs 的 nodejs express 渲染
- javascript - 在节点提示符中隐式调用什么来输出文本?
- keras - Keras - 通过每个通道的不同均值和标准进行归一化
- python-3.x - 无法使用 python 请求上传二进制数据
- typescript - 如何使用可变文本内容进行断言
- javascript - 通过 javascript 将 HTML 元素附加到 DOM 后获取
- flutter - dart/flutter 根据来自同一组记录的键值查找另一个键的值
- elasticsearch - 在 Elasticsearch 中查询没有匹配项
- xml - 如果xml中缺少标签,为什么会显示文本?