-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCrowler.h
More file actions
45 lines (39 loc) · 1.85 KB
/
Crowler.h
File metadata and controls
45 lines (39 loc) · 1.85 KB
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
#ifndef CROWLER_H
#define CROWLER_H
#include <string>
#include <regex>
#include <vector>
#include <thread>
#include "SafeQueue.h"
class Crowler
{
private:
// вектор для хранения потоков обработки задач
std::vector<std::thread> threadsPool_;
// очередь задач на обработку
SafeQueue tasksQueue_;
// скачивание html по url
std::string download(std::string domain, std::string path);
// получение данных из HTML
std::vector<std::string> getDataFromHtml(std::string s, std::regex filter);
// получение слов из скачанного html
std::vector<std::string> getWords(std::string innerHtml);
// получение ссылок из скачанного html
std::vector<std::string> getSubUrls(std::string innerHtml);
// вычисление частот слов и сохранение данных в базу
void savePresencesToDb(std::vector<std::string> words, std::string url);
// обход ресурса
void processUrl(std::string domain, std::string path, short depth);
// добавление задачи в очередь на обход
void addToCrowlingQueue(std::string domain, std::string pat, unsigned short depth);
// методя для взятия очередной задачи на процессинг ресурса из очереди задач и процессинга
void work();
// метод для разложения внутреннего url на domain и path
std::pair<std::string, std::string> parseSubUrl(std::string domain, std::string subUrl);
public:
Crowler();
~Crowler();
// метод запуска процессинга стартового ресурса (из конфига)
void processStartPage();
};
#endif // CROWLER_H