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="hentry hentry--item hentry--banner">/,/<\/div>/ {
28 next
29 }
30 /<div class="item_tag_single">/,/<\/div>/ {
31 next
32 }
33 /<div class="item_share_inline">/,/<\/div>/ {
34 next
35 }
36 /<div class="item_tags" itemprop="keywords">/,/<\/div>/ {
37 next
38 }
39 /<div class="item_subscribe">/,/<\/div>/ {
40 next
41 }
42 /<div class="content_date">/,/<\/div>/ {
43 next
44 }
45
46 {
47 # Remove all img-s
48 gsub(/<img [^>]+\/?>/, "")
49
50 print
51 }
52 '
53
54 }
55
56
57 url=$2
58 curl -Lgs -- "${url}" |
59 extract_article |
60 filter_html |
61 html_to_text
62
63 echo ""
64 echo "URL: <${url}>"