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         /<body/,/<\/body>/ {
           14                 print
           15         }
           16         '
           17 }
           18 
           19 
           20 #
           21 # Filter HTML content
           22 #
           23 filter_html()
           24 {
           25 
           26         awk '
           27         /<div class="PageHeadline">/,/<\/div>/ {
           28                 print
           29         }
           30 
           31         /<div class="ArticleText">/,/<\/div> <!-- ArticleText -->/ {
           32                 if ($0 !~ /Log in<\/a> to post comments\)/) {
           33                         print
           34                 }
           35         }
           36 
           37         '
           38 
           39 }
           40 
           41 
           42 url=$2
           43 curl -Lgs -- "${url}" |
           44     extract_article |
           45     filter_html |
           46     html_to_text
           47 
           48 echo ""
           49 echo "URL: <${url}>"