]> Cypherpunks.ru repositories - nncp.git/blob - doc/integration/warc.texi
Split integration pages
[nncp.git] / doc / integration / warc.texi
1 @node WARCs
2 @section Integration with Web pages
3
4 Simple HTML web page can be downloaded very easily for sending and
5 viewing it offline after:
6
7 @example
8 $ wget http://www.example.com/page.html
9 @end example
10
11 But most web pages contain links to images, CSS and JavaScript files,
12 required for complete rendering.
13 @url{https://www.gnu.org/software/wget/, GNU Wget} supports that
14 documents parsing and understanding page dependencies. You can download
15 the whole page with dependencies the following way:
16
17 @example
18 $ wget \
19     --page-requisites \
20     --convert-links \
21     --adjust-extension \
22     --restrict-file-names=ascii \
23     --span-hosts \
24     --random-wait \
25     --execute robots=off \
26     http://www.example.com/page.html
27 @end example
28
29 that will create @file{www.example.com} directory with all files
30 necessary to view @file{page.html} web page. You can create single file
31 compressed tarball with that directory and send it to remote node:
32
33 @example
34 $ tar cf - www.example.com | zstd |
35     nncp-file - remote.node:www.example.com-page.tar.zst
36 @end example
37
38 But there are multi-paged articles, there are the whole interesting
39 sites you want to get in a single package. You can mirror the whole web
40 site by utilizing @command{wget}'s recursive feature:
41
42 @example
43 $ wget \
44     --recursive \
45     --timestamping \
46     -l inf \
47     --no-remove-listing \
48     --no-parent \
49     [...]
50     http://www.example.com/
51 @end example
52
53 There is a standard for creating
54 @url{https://en.wikipedia.org/wiki/Web_ARChive, Web ARChives}:
55 @strong{WARC}. Fortunately again, @command{wget} supports it as an
56 output format.
57
58 @example
59 $ wget \
60     --warc-file www.example_com-$(date '+%Y%M%d%H%m%S') \
61     --no-warc-compression \
62     --no-warc-keep-log \
63     [...]
64     http://www.example.com/
65 @end example
66
67 That command will create uncompressed @file{www.example_com-XXX.warc}
68 web archive. By default, WARCs are compressed using
69 @url{https://en.wikipedia.org/wiki/Gzip, gzip}, but, in example above,
70 we have disabled it to compress with stronger and faster
71 @url{https://en.wikipedia.org/wiki/Zstd, zstd}, before sending via
72 @command{nncp-file}.
73
74 There are plenty of software acting like HTTP proxy for your browser,
75 allowing to view that WARC files. However you can extract files from
76 that archive using @url{https://pypi.python.org/pypi/Warcat, warcat}
77 utility, producing usual directory hierarchy:
78
79 @example
80 $ python3 -m warcat extract \
81     www.example_com-XXX.warc \
82     --output-dir www.example.com-XXX \
83     --progress
84 @end example