User:Rick Bot/scripts/get formers

#!/bin/bash

# get the former featureds
/usr/bin/curl "http://en.wiki.x.io/w/index.php?title=Wikipedia:Former_featured_articles&action=raw"	2>/dev/null | awk '

/^==Former featured articles that have been re-promoted/ {
  nextfile
}

/Contents/ {
 seencontents = 1
}

/[[][[]/ {
  if (seencontents==0) {
    next
  }
  sub("^[^[]*[[][[]","",$0)
  sub("]].*","",$0)
  sub("[|].*","",$0)
  if ( substr($0,1,1) != "#" ) {
    former[$0] = 1
  }
}

END {
  for (art in former) {
    print "FORMER||" art
  }
}' >formers