-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
46 lines (38 loc) · 823 Bytes
/
Copy pathmain.cpp
File metadata and controls
46 lines (38 loc) · 823 Bytes
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
37
38
39
40
41
42
43
44
45
46
// main file
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include "gumbo.h"
#include "utils.h"
#include "crawler.h"
using namespace std;
int main(int argc, char *argv[]){
cout << "Spiderman wakes up..." << endl;
//the url that will be entered
string host = argv[1];
//ensure host is in valid format
host = Utils::reformatHost(host);
int depth;
//sstream object
istringstream iss(argv[2]);
//valid number checking
if(!(iss >> depth))
{
cout << "Invalid number: " << argv[2] << "\n";
return 0;
}
else
{
//if valid save to int
iss >> depth;
}
cout << "Starting from :" << host << endl;
// Start crawling
Crawler c;
c.crawl(host, depth);
cout << "Spiderman goes to sleep..." << endl;
return 0;
}