article.cgi - gophercgis - Collection of gopher CGI/DCGI for geomyidae
(HTM) hg clone https://bitbucket.org/iamleot/gophercgis
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
article.cgi
---
1 #!/bin/sh
2
3 . ../common/config.sh
4 . ../common/html.sh
5
6 #
7 # Extract article content
8 #
9 extract_article()
10 {
11
12 awk '
13 /<article/,/<\/article>/ {
14 print
15 }
16 '
17 }
18
19
20 #
21 # Filter HTML content
22 #
23 filter_html()
24 {
25
26 awk '
27 /<div class="meta__extras/,/<\/div>/ {
28 next
29 }
30
31 /<div class="after-article js-after-article">/,/<\/article>/ {
32 next
33 }
34 /<div class="submeta">/,/<\/article>/ {
35 next
36 }
37
38 {
39 print
40 }
41 '
42
43 }
44
45
46 url=$2
47 curl -Lgs -- "${url}" |
48 extract_article |
49 filter_html |
50 html_to_text
51
52 echo ""
53 echo "URL: <${url}>"