Saving a webpage to disk using C++

浪子不回头ぞ 提交于 2019-11-29 17:55:08
JosephH

If your program is going to run both on windows and unix, then use cURL. Otherwise, stick with MSVC and WinINet functions http://msdn.microsoft.com/en-us/library/windows/desktop/aa385473(v=vs.85).aspx It's much easier to use in terms of the efforts required to get your program running and distributed (esp. if you're not linking your program against cUrl statically. Otherwise, you'll need to take libcurl.dll everywhere your program runs on Windows). With WinINet, you simply need to include a header and a library to use the functions.

If you're going to use WinINet, refer to this code snippet: http://www.programmershelp.co.uk/showcode.php?e=57 Use the same code except for the while loop. Instead of reading one byte at a time, read them by chunks and write them to the output file handle.

If you're going to use cURL, refer to this post: Download file using libcurl in C/C++

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!