]> git.lizzy.rs Git - plan9front.git/blob - rc/bin/ap
merge
[plan9front.git] / rc / bin / ap
1 #!/bin/rc
2 #
3 #       get AP news headline list or the given story
4 #
5
6 wire='http://www.newsday.com/news/nationworld/wire'
7 if ( ~ $#* 0 )
8         hget $wire | #tee /tmp/ap.$pid |
9                 sed -n '/<h1>AP Top News/,/AP News Wire/p' |
10                 htmlfmt -a -w 100 |
11                 sed -n '
12                         /^• / {
13                                 N
14                                 s/^• / /g
15                                 s/\n/ /g
16                                 s/\[\/news\/nationworld\/wire\//|/
17                                 s/sns-ap-//
18                                 s/\.story.*$//
19                                 p
20                 }' |
21                 awk -F '|' '
22                         {
23                         s = "";
24                         for (i = 1; i < NF; i++)
25                                 s = s " " $i;
26                         printf("ap %-40s # %s\n", $NF, s);
27                 }'
28
29 if not
30         hget $wire/sns-ap-^$1^.story |
31                 htmlfmt |
32                 sed '
33                         1,/^AP Top News$/d
34                         /^\* __$/,$d
35                         /^Subscribe to Newsday home delivery/,$d
36                 '