2

HTML ソース コードを文字列に読み込む必要があるプログラムを作成しています。

C# の WebClient について読んだことがありますが、C++ でプログラムを作成する必要があり、その方法がわかりません (これまで WebClient を使用したことがありません)。

WebClient を使用して HTML ソース コードを文字列に変換する方法を示す簡単な C++ サンプル プログラムを誰か教えてもらえますか? (またはより良い方法)

ありがとう。

4

2 に答える 2

2

A Fully Featuresed Windows HTTP Wrapper in C++ のページを参照してください。

http://www.codeproject.com/Articles/66625/A-Fully-Featured-Windows-HTTP-Wrapper-in-C

そのページのサンプルコードは、あなたが望むもののように見えます:

void ProgressTest(void)
{
    // Set URL and call back function.
    WinHttpClient client(L"http://www.codeproject.com/", ProgressProc);
    client.SendHttpRequest();
    wstring httpResponseHeader = client.GetResponseHeader();
    wstring httpResponseContent = client.GetResponseContent();
}
于 2013-03-03T13:34:33.110 に答える
-2

c# の webclient が何かわかりません。ファイルを文字列に読み込むには-:

 std::ifstream ifs("webpage.html");
 std::string str;
 str.assign((std::istreambuf_iterator<char>(ifs)),
            (std::istreambuf_iterator<char>()));
于 2013-03-03T13:29:48.543 に答える