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         /<header class="header-news">/,/<\/header>/ {
           28                 print
           29         }
           30 
           31         /<div itemprop="articleBody" class="news-txt">/,/<\/div>/ {
           32                 print
           33         }
           34         '
           35 
           36 }
           37 
           38 
           39 url=$2
           40 curl -Lgs -- "${url}" |
           41     extract_article |
           42     filter_html |
           43     html_to_text
           44 
           45 echo ""
           46 echo "URL: <${url}>"