-
//#include <Windows.h> #include <string> #include <iostream> #include <fstream> #include <vector> #include "winsock2.h" #include <time.h> #include <queue> #include <hash_set> #pragma comment(lib, "ws2_32.lib") using namespace std; #define DEFAULT_PAGE_BUF_SIZE 1048576 queue<string> hrefUrl; hash_set<string> visitedUrl; hash_set<string> visitedImg; int depth=0; int g_ImgCnt=1; //解析URL,解析出主机名,资源名 bool ParseURL(const string &url, string &host, string &resource) { if(strlen(url.c_str()) > 2000) { return false; } const char *pos=strstr(url.c_str(),"http://"); if( pos==NULL ) pos = url.c_str(); else pos += strlen("http://"); if( strstr( pos, "/")==0 ) return false; char pHost[100]; char pResource[2000]