简体   繁体   English

如何在我的不和谐机器人上显示来自网站的信息?

[英]How to display information from a website on my discord bot?

Im building a discord bot(Javascript, Node.js, Discord.js) which is based on a game (a online multiplayer).So, im pretty much done developing the bot except for one thing which I really wish I could add.我正在构建一个基于游戏(在线多人游戏)的 discord bot(Javascript、Node.js、Discord.js)。所以,除了我真的希望我可以添加的一件事之外,我几乎完成了开发该机器人的工作。 So, this game has some highscores which can be viewed here - https://www.hzgaming.net/high.php .所以,这个游戏有一些高分,可以在这里查看 - https://www.hzgaming.net/high.php So, I want to display those highscores (Highscore money - https://www.hzgaming.net/high.php?scores=money ) (Highscore materials - https://www.hzgaming.net/high.php?scores=materials ) and all those.所以,我想显示那些高分(高分钱 - https://www.hzgaming.net/high.php?scores=money )(高分资料 - https://www.hzgaming.net/high.php?scores=材料)和所有这些。 So, what I would like to have is..when a user types a cmd like '!highscore money', it should show the highscore available on that website link I gave above, and similarly..when they use '!highscore materials' it should show the highscore of materials from that link respectivly.所以,我想要的是..当用户输入像'!highscore money'这样的cmd时,它应该显示我上面给出的那个网站链接上可用的高分,同样......当他们使用'!highscore材料'时它应该分别显示来自该链接的材料的高分。 I want it to be from that link because, it keeps on changing and gets updated.我希望它来自该链接,因为它不断变化并得到更新。 Also, im pretty sure its possible because, there is a similar bot which shows the same thing as I explained.另外,我很确定这是可能的,因为有一个类似的机器人显示与我解释的相同的内容。 I hope you understood what I meant.我希望你明白我的意思。 I would really love to get an answer for this, also it would be great if an example code is provided with the answer so that its easy to understand.我真的很想得到一个答案,如果提供了一个示例代码以使其易于理解,那就太好了。

An example for the cmd is given below -下面给出了 cmd 的示例 -

user - !highscore money BOT - Money High Scores用户 - !highscore money BOT - 金钱高分

  1. Celia_Fernandz - $41,085,610 total wealth Celia_Fernandz - 总财富为 41,085,610 美元
  2. Armando_Domrani - $40,204,664 total wealth Armando_Domrani - 总财富 40,204,664 美元
  3. Sergio_Box - $38,199,486 total wealth Sergio_Box - 总财富为 38,199,486 美元
  4. Tony_Sativa - $30,193,261 total wealth Tony_Sativa - 总财富为 30,193,261 美元
  5. Aminox_Trigui - $28,052,188 total wealth Aminox_Trigui - 总财富为 28,052,188 美元
  6. Ben_Martin - $23,439,003 total wealth Ben_Martin - 总财富为 23,439,003 美元
  7. Daryl_Grimes - $17,128,518 total wealth Daryl_Grimes - 总财富 17,128,518 美元
  8. Luccas_Von_Koening - $16,457,964 total wealth Luccas_Von_Koening - 总财富为 16,457,964 美元
  9. Charlie_Hustle - $14,452,056 total wealth Charlie_Hustle - 总财富为 14,452,056 美元
  10. Kevin_Maddox - $13,630,605 total wealth Kevin_Maddox - 总财富为 13,630,605 美元

user- !highscore materials BOT - 1. Chapo_Diamond - 5,749,300 materials 2. Van_Damme - 4,923,046 materials 3. Brandon_Heath_Tsung - 3,906,395 materials 4. Armando_Domrani - 3,241,925 materials 5. Tazz_Equinox - 3,187,045 materials 6. Danny_Ted - 2,868,088 materials 7. Jack_Paterson - 2,748,249 materials 8. John_Dixon - 2,548,250 materials 9. Gab_Alphonse - 2,252,285 materials 10. Don_Thomax - 2,131,177 materials (( ALL THE REPLY BY THE BOT WILL BE EMBEDS )) (yea, so somehow those values should keep on updating, thats why I gave the link above)用户的高分材料BOT - 1 Chapo_Diamond - 5749300种材料2. Van_Damme - 4923046种材料3. Brandon_Heath_Tsung - 3906395种材料4. Armando_Domrani - 3241925种材料5. Tazz_Equinox - 3187045种材料6. Danny_Ted - 2868088种材料7. Jack_Paterson - 2748249种材料8 . John_Dixon - 2,548,250 材料 9. Gab_Alphonse - 2,252,285 材料 10. Don_Thomax - 2,131,177 材料((机器人的所有回复都将嵌入))(是的,所以不知何故,这些值应该继续更新)

Pls note that the code should be javascript using discord.js and node.js.请注意,代码应该是使用 discord.js 和 node.js 的 javascript。 Thank you <3 :)谢谢<3 :)

I'm not sure if that's possible because of the "Just checking your computer, this will only take a few seconds" page that will always pop up (for DDoS protection).我不确定这是否可能,因为“只是检查您的计算机,这将只需要几秒钟”页面总是会弹出(用于DDoS保护)。 For example, this is what I got in my console after requesting some data:例如,这是我在请求一些数据后在我的控制台中得到的:

<!DOCTYPE html>
<html>
        <head>
                <meta charset="UTF-8">
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
                <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
                <meta name="robots" content="noindex, nofollow">
                <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
                <meta http-equiv="refresh" content="12">
                <link rel="Shortcut Icon" href="https://www.hzgaming.net/favicon.ico" type="image/x-icon">
                <title>Just a moment...</title>
                <style>@font-face{font-family:Open Sans;font-style:normal;font-weight:400;font-display:swap;src:local("Open Sans Regular"),local("OpenSans-Regular"),url(data:font/woff2;base64,
d09GMgABAAAAACjgAA4AAAAAUhQAACiIAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGiIbEBwaBmAAZBEQCoGANONLC4
M8AAE2AiQDhnAEIAWDWgeQShv4QBXjmFXAxsEAi709IypHX42iQhIH/39MoGOIFG6KqtsXWLsNGTEJswgLuVELAuzt
6BPcQHcKGcv5HKXdi+eKlYT6O/H7D3cgR+jqXNVLasoPuSn55q2H3pbvh3OAu9IvBQY5QmOf5EL/td9nz5tz7szuhl
FHoURhUQJqVpEko1I+Ki4WZRSx2vo+qLaiHszxbb7Ne0BkhgdhTe1mgqThm6figcxKku0p+W2vqybIl4ofbmvDwzr/

// and so on... for a very long time.

I don't think there's a way to get past this, but in the miraculous chance you find a way, this is how I would get the needed data:我不认为有办法解决这个问题,但是在你找到方法的奇迹般的机会中,这就是我获取所需数据的方式:

// you should use this npm package - https://www.npmjs.com/package/node-fetch
const fetch = require('node-fetch');

fetch('https://www.hzgaming.net/high.php?scores=money')
      .then((res) => res.text())
      .then((body) => console.log(body));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我该如何编码Discord机器人以从网站提取文字? - How do I code a discord bot to extract text from a website? 是否可以从网站运行不和谐机器人命令 - Is it possible to run a discord bot comand from a website Discord bot 网站,如何获得公会计数 - Discord bot website, how to get Guild count 如何为我的 Discord 机器人提供的统计信息创建嵌入(Covid Statistics) - How to create an embed for statistical information provided by my Discord bot (Covid Statistics) 如何让我的 Discord Bot 回复并提及? - How to make my Discord Bot reply with a mention? 如何显示来自另一个网站的XML文件中包含的信息 - How to display information contained in XML file from another website 有没有办法从与我的机器人不在同一个公会的用户那里获取 discord 用户信息(头像、帐户创建日期等)? - Is there a way to get discord user information (avatar, account creation date, etc.) from users that are NOT in the same guild as my bot? 如何在我的网站上显示来自 API 的数字? - How to display a number from an API on my website? Discord Bot - 从网站下载 JSON 文件并提取其中的某些元素 - Discord Bot - Downloading JSON file from a website and extract certain elements of it 如何在网站上制作 discord.js 机器人统计信息? - How I can make discord.js bot statistics on website?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM