Last active
August 29, 2015 13:57
-
-
Save elhoucine/9628834 to your computer and use it in GitHub Desktop.
mad-equals
This file contains hidden or 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
from os import system | |
from urllib import urlopen | |
from re import compile, findall | |
from datetime import datetime | |
currencies=["eur","usd","gbp","aud","cad","chf"] | |
currenciesLongName={currencies[0]:"Euro", | |
currencies[1]:"US Dollar", | |
currencies[2]:"British Pound", | |
currencies[3]:"Australian Dollar", | |
currencies[4]:"Canadian Dollar", | |
currencies[5]:"Swiss Franc"} | |
now = datetime.now().strftime('%d/%m/%Y %H:%M:%S') | |
history = open("memo.txt","a") | |
history.write("Date : "+now+"\n") | |
i=0 | |
while i<len(currencies): | |
madvalue=findall(compile('<b>(.+?)</b>'), urlopen("http://themoneyconverter.com/"+ currencies[i] +"/MAD.aspx").read()) | |
if madvalue : | |
result = currencies[i] + " = "+madvalue[-1]+"Dirham(s). "+"("+currenciesLongName[currencies[i]]+")" | |
else: | |
result = "It seems u didn't get any info for : "+currenciesLongName.value[i] | |
print result | |
history.write(result+"\n") | |
i+=1 | |
history.write("\n---\n\n") | |
history.close() | |
os.system("pause") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment