Download HTML content Save to File

xiaoxiao2021-03-06  42

#include #include using namespace std;

Bool Readhtml (String Url, String & S) {CinternetSession Session ("UnkNown"); Chttpfile * Pfile = (chttpfile *) session.OpenURL (url.c_str ()); if (pfile) {charf [8192]; // = {0}; int count; for (;;) {count = pfile-> read (buf, sizeof (buf) - 1); if (count <= 0) Break; buf [count] = 0; S.Append (BUF);} pfile-> close (); delete pfile; return;} Return False;} Bool Savefile (String file, string & s) {cfile cf (file.c_str (), cfile :: modecreate | cfile :: MODECREATE ModeWrite); cf.writehuge (s.c_str (), s.size ()); //cf.flush (); cf.close (); return true;}

Main () {string s; if ("http://www.google.com", s)) Savefile ("c: //google.html", s);}

转载请注明原文地址:https://www.9cbs.com/read-63624.html

New Post(0)