-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.cpp
47 lines (35 loc) · 1.05 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
#include "cnp.h"
#include <cstring>
#include <fstream>
#include <iostream>
#include <string>
int main() {
std::string url = "https://lichess.org/";
cnp::init();
std::string result_text = cnp::download_page(url);
std::string plain_text = cnp::html_to_text(result_text);
std::cout << cnp::get_webpage_text(url) << std::endl;
std::vector<std::string> result;
result = cnp::get_tags_to_array(result_text, "a");
std::cout << result.size() << std::endl;
for (auto s : result) {
std::cout << s << std::endl;
}
std::vector<std::string> elements =
cnp::find_elements_by_class(result_text, "site-name");
for (auto s : elements) {
std::cout << s << std::endl;
}
std::vector<std::string> attr_test =
cnp::find_elements_by_attr_val(result_text, "target", "_blank");
for (auto s : attr_test) {
std::cout << s << std::endl;
}
std::vector<std::string> urls_in_webpage =
cnp::extractUrls(result_text);
for (auto s : urls_in_webpage) {
std::cout << s << std::endl;
}
cnp::cleanup();
return 0;
}