首页 > 解决方案 > 如何检查网站显示的真假?

问题描述

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!');
}

用户名被拒绝。因此,当我执行命令时,它只发送嵌入而不发送其他任何内容。我很坚持这一点

标签: javascriptdiscord.jsroblox

解决方案


使用axios获取网页。

axios.get(tokenID).then(({data}) => {
   console.log(data) // debug
   const bought = data === 'true'
   // ...send message to user
})

推荐阅读