-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCrawlerDriver.cpp
36 lines (29 loc) · 902 Bytes
/
CrawlerDriver.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <cstdlib>
#include "Crawler.h"
#include "Common.h"
int main(int argc, char **argv)
{
if(argc != 2) {
cerr << "Usage: " << argv[0] << "numThreads" << endl;
exit (1);
}
int numThreads = atoi(argv[1]);
if(numThreads <= 0) {
cerr << "numThreads <= 0 error" << endl;
exit(1);
}
ifstream urlSeedIfs(URL_PATH.c_str());
if(!urlSeedIfs) {
cerr << "open file " << URL_PATH << " error" << endl;
exit(1);
}
ofstream rawPagesOfs(RAW_PAGES_PATH.c_str());
if(!rawPagesOfs) {
cerr << "open file " << RAW_PAGES_PATH << " error" << endl;
exit(1);
}
Crawler crawler(urlSeedIfs, rawPagesOfs, numThreads);
crawler.multiPthreadCrawl();
return 0;
}