Hacker News new | ask | show | jobs
by Aptrug 1594 days ago
I was curious to know which locations are ranked the highest, so I made this quick 'n' dirty shell script:

    #!/bin/sh
    curl -s 'https://news.ycombinator.com/item?id=30210378' | awk '
    BEGIN {
        FS = "[<>]"
    }
    {
        for (i = 1; i <= NF; ++i) {
            if ($i == "font color=\"#000000\"") {
                printf "%s, ", $(i+1)
            } else if ($i ~ /^span class="score" id="score_/) {
                print $(i+1)
            }
        }
    }
    ' | sort -t',' -nk2
It scrapes the web page, so it's kind of fragile.
1 comments

Working well for me! Thanks.