#!/bin/bash

# wminfo plugin: currencies exchange rates of Polish zloty (buy)

# command: wminfo -p currencies-pl-buy.wmi -b#333251 -f#ffffff

lynx --source http://wyborcza.biz/Waluty/0,111138,8938582,,,Kursy_kupna_sprzedazy_walut_NBP,C.html?piano_t=1 | \
    perl -pe 's/\n//;s/<td class=(.*)?>/\n<td class=$1>/g' | \
    grep 'td class' | grep -E 'symbol|buy' | \
    grep -v 'buychange' | \
    perl -pe 's/<\/strong>.*/<\/strong>/g;s/<\/a><\/strong>\n//' | \
    tr '\r\t' ' ' | \
    perl -pe 's/<.*?>/ /g;s/ +/ /g' | \
    perl -pe 's/ [0-9]+ ([A-Z]+) \n/$1/' | \
    perl -pe 's/HUF (.)\.(....)/HUF 0.0$1$2/;s/JPY (.)\.(....)/JPY 0.0$1$2/' | \
    sort
echo
