remwharead  0.6.3
uri.hpp
1 /* This file is part of remwharead.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef REMWHAREAD_URI_HPP
18 #define REMWHAREAD_URI_HPP
19 
20 #include <string>
21 
22 namespace remwharead
23 {
24  using std::string;
25 
27  typedef struct html_extract
28  {
29  string title;
30  string description;
31  string fulltext;
32  } html_extract;
33 
41  class URI
42  {
43  public:
45  explicit URI(const string &uri);
46  ~URI();
47 
49  const html_extract get();
50 
52  const string archive();
53 
54  protected:
55  string _uri;
56 
58  const string make_request(const string &uri) const;
59 
61  const string extract_title(const string &html);
62 
64  const string extract_description(const string &html);
65 
67  const string strip_html(const string &html);
68 
75  const string remove_html_tags(const string &html,
76  const string &tag = "");
77 
79  const string unescape_html(const string &html);
80 
82  const string remove_newlines(string text);
83  };
84 }
85 
86 #endif // REMWHAREAD_URI_HPP
A processed HTML page.
Definition: uri.hpp:27
URI(const string &uri)
Construct object and set URL.
Definition: uri.cpp:56
const string remove_html_tags(const string &html, const string &tag="")
Remove HTML tags.
Definition: uri.cpp:230
Definition: bookmarks.cpp:22
const string strip_html(const string &html)
Removes HTML tags and superflous spaces from an HTML page.
Definition: uri.cpp:211
const string remove_newlines(string text)
Replace newlines with spaces.
Definition: uri.cpp:598
const string unescape_html(const string &html)
Convert HTML entities to UTF-8.
Definition: uri.cpp:268
const string extract_title(const string &html)
Extract the title from an HTML page.
Definition: uri.cpp:184
Download, archive and process an URI.
Definition: uri.hpp:41
const string archive()
Save URI in archive and return archive-URI.
Definition: uri.cpp:568
const string extract_description(const string &html)
Extract the description from an HTML page.
Definition: uri.cpp:197
const string make_request(const string &uri) const
Make a HTTP(S) request.
Definition: uri.cpp:129