Last active
November 4, 2015 06:25
-
-
Save kputnam/5af49158d81650374ecb to your computer and use it in GitHub Desktop.
Formats and prints recent StackOverflow careers postings to console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use URI::Escape; | |
my $url = 'http://careers.stackoverflow.com/jobs/feed?searchTerm='; | |
# Either use search terms given as command-line arguments, or use default terms | |
my $q = join('+', map { uri_escape($_); } (@ARGV > 0) ? | |
@ARGV : ('-.net', '-css', '-c#', '-android', '-php', '-ios', '-vb.net', '-excel' )); | |
# Read XML from child process | |
open(INPUT, "-|") || exec "curl -# '$url$q' | xmllint --format -"; | |
# Reopen STDOUT so output is sent to pager | |
unless (-t STDOUT) { | |
my $pager = $ENV{PAGER} || '/usr/bin/less'; | |
open(STDOUT, "| $pager"); | |
} | |
while (<INPUT>) { | |
s/</</g; | |
s/>/>/g; | |
s/&/&/g; | |
s/&/&/g; | |
s/ / /g; | |
s/©/(C)/g; | |
s/™/(TM)/g; | |
s/£/£/g; | |
s/€/€/g; | |
s/”/"/g; | |
s/“/"/g; | |
s/„/"/g; | |
s/’/'/g; | |
s/‘/'/g; | |
s/–/-/g; | |
s/—/-/g; | |
s/\xc2\x92/'/g; | |
s/…/.../g; | |
s/ß/ß/g; | |
s/&(.)uml;/$1/g; | |
s/&(.)circ;/$1/g; | |
s/&(.)ring;/$1/g; | |
s/&(.)slash;/$1/g; | |
s/&(.)tilde;/$1/g; | |
s/&(.)acute;/$1/g; | |
s/&(.)cedil;/$1/g; | |
s/&(.)grave;/$1/g; | |
s/<p>/\n/g; | |
s/<\/p>/\n/g; | |
s/<br>/\n/g; | |
s/<br \/>/\n/g; | |
s/<li>\s*/* /g; | |
s/<(a|b|em|strong|span|ul|ol)( [^>]*)?>//g; | |
s/<\/(a|b|em|strong|span|li|ul|ol)>//g; | |
s/\n\n+/\n\n/g; | |
s/^<\/description/ <\/description/mg; | |
print $_; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment