简体   繁体   English

如何将网站中的文本复制到 C++ 中的字符串?

[英]How can I copy the text from a website to a string in c++?

I am trying to connect to an online API, get all the text on the website, and copy+paste it to a string.我正在尝试连接到在线 API,获取网站上的所有文本,然后将其复制并粘贴到字符串中。

The URL is https://api.hypixel.net/skyblock/bazaar?key=[KEYHERE] And https://api.hypixel.net/skyblock/profile?key=[MyKey]&profile=[MyProfile] (the URL is censored). URL 是https://api.hypixel.net/skyblock/bazaar?key=[KEYHERE]https://api.hypixel.net/skyblock/profile?key=[MyKey]&profile=[MyProfile](URL被审查)。

this is my code so far:到目前为止,这是我的代码:

#include <iostream>
#include <windows.h>
#include <string>
#include <cstdlib>
using namespace std;

int main()
{
    string URLPurse = "https://api.hypixel.net/skyblock/profile?key=[MyKey]&profile=[MyProfile]";
    string URLEnder = "https://api.hypixel.net/skyblock/bazaar?key=[MyKey]";
    //read text from both APIs
    string answerPurse = [text from the player api];
    string answerEnder = [text from the bazzar api];

    // Do stuff with the text
}

I am EXTREAMLY new to programming and I don't know how to download or use cURL, but is there a way to do it without external libraries?我对编程非常陌生,我不知道如何下载或使用 cURL,但是有没有办法在没有外部库的情况下做到这一点? if there isn't can you explain how can I download and use cURL to achieve this?如果没有,您能解释一下我如何下载和使用 cURL 来实现这一目标吗? (I am using Windows 7 with 32-bit and Code::Blocks). (我使用的是带有 32 位和 Code::Blocks 的 Windows 7)。 I also can't use any other programming languages like java for example.例如,我也不能使用任何其他编程语言,例如 java。

(I know I use too many libraries) (我知道我使用了太多的库)

尝试使用 selenium,它是在 python 中的,我也相信 c++,你可以定位 html 元素并使用它们,但是你喜欢

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM