How to download webpage into string without saving this page to disk in C++?
URLDownloadToFile MSDN function only saving page into disk.
How to download webpage into string without saving this page to disk in C++?
URLDownloadToFile MSDN function only saving page into disk.
Did you look up the other URLXXX
functions mentioned thereof? How about: URLOpenBlockingStream
?
//implement filestream that derives from IStream
class StringStream : public IStream
{
StringStream(std::wstring buf)
{
_refcount = 1;
_mBuf = buf;
}
~ StringStream ()
{
}
// implement IUknown, IStream interfaces
private:
std::wstring _mBuf;
long _refcount;
};
See the default file based IStream implementation here.
But how to read that IStream to string? I got
IStream* pStream;
string text;
URLOpenBlockingStream(NULL, "http://www.mysexyserver.com/text.txt", &pStream, 0, NULL);
text =pStream;
cout << text << endl;
This not works