Skip to content

Instantly share code, notes, and snippets.

@elhoucine
Last active August 29, 2015 13:57
Show Gist options
  • Save elhoucine/9628834 to your computer and use it in GitHub Desktop.
Save elhoucine/9628834 to your computer and use it in GitHub Desktop.
mad-equals
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