Skip to content

Instantly share code, notes, and snippets.

@drgarcia1986
Created June 30, 2015 16:36
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save drgarcia1986/dba71fd0101258745692 to your computer and use it in GitHub Desktop.
Cotação do dólar baseada no site http://dolarhoje.com/
# -*- coding: utf-8 -*-
import urllib.request
import re
resp = urllib.request.urlopen('http://dolarhoje.com/').read()
resp = resp.decode('utf-8')
dolar = re.search(
r'<input type="text" id="nacional" value="(?P<dolar>[^"]+)"/>', resp
)
if dolar:
print('US$ 1,00 vale R$ {}'.format(dolar.group(1)))
else:
print('Não foi possível converter o dolar =(')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment