-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
63 lines (49 loc) · 1.6 KB
/
main.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include "scraper.h"
using namespace std;
static bool forever = true;
int main(int argc, char *argv[])
{
char ch;
unordered_map<std::string, WebTitle> webSites;
const char * attrTime[] = { "class",
"cluster"};
const char * attrEspn[] = { "class",
"contentItem__titleWrapper"};
const char * attrFoxNews[] = { "class",
"content" };
const char * attrNBCNews[] = { "class",
"info___1Xmsp pt5 pt0 ph5 pl4-m"};
webSites.insert({
{"www.time.mk", WebTitle( std::string("div") , attrTime )},
{"www.espn.com", WebTitle( std::string("div"), attrEspn )},
{"www.foxnews.com", WebTitle( std::string("div"), attrFoxNews )},
{"www.nbcnews.com", WebTitle( std::string("div"), attrNBCNews )}
}
);
Scraper sc(webSites);
while (forever) {
cerr << "press e to exit ===>";
cin >> ch;
switch (ch) {
case 's':
sc.startScraping();
break;
case 'h':
{
string webSite;
cin >> webSite;
try {
cerr << "WebSite: " << webSite << "\nHeadLine news => " << sc.getHeadline(webSite) << endl;
} catch (out_of_range &e) {
cerr << e.what() << endl;
}
}
break;
case 'e':
forever = false;
break;
}
}
return 0;
}