httpget.cpp
#include "weHtmlEntity.h"
#include "weHTTP.h"
#include "weTask.h"
#include "weHelper.h"
using namespace std;
int main(int argc, char* argv[])
{
WeHTTP proc;
WeHtmlDocument doc;
WeHttpResponse resp;
WeLibInit();
proc.Option(weoCollapseSpaces, true);
proc.Option(weoStayInHost, true);
proc.Option(weoFollowLinks, true);
proc.RelocationCount(10);
proc.Request("http://www.ru", &resp);
while (!resp.Processed()) {
proc.ProcessRequests();
}
printf("Response: %d\n", resp.HttpCode());
printf("Given URL: %s\n", resp.BaseUrl().ToString().c_str());
printf("Relocations: %d\n", resp.RelocCount());
printf("Resulting URL: %s\n", resp.RealUrl().ToString().c_str());
printf("Data size: %d\n", resp.Data().size());
if (resp.Data().size() > 0) {
bool sc = doc.ParseData(&resp, &proc);
printf("Document parsing: %s\n", (sc?"success":"fail"));
printf("%s\n", &(doc.Data()[0]));
}
WeLibClose();
return 0;
}