-
-
Save 2bj/120620 to your computer and use it in GitHub Desktop.
Курсо-валют-дёргалко с мега сайта www.nbkr.kg
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Курсо-валют-дёргалко с мега сайта www.nbkr.kg | |
@author 2bj (dev2bj at gmail) | |
@requirements: | |
- urllib | |
- re | |
""" | |
import urllib | |
import re | |
html=urllib.urlopen('http://www.nbkr.kg/').read().decode('CP1251') | |
patt1=re.compile(r'<td\b[^>]*class=\"informer_header\"[^>]*>(.*)<\/table>') | |
m1=patt1.findall(html) | |
patt2=re.compile(u'Официальные курсы валют\s*</a>\s*<br>\s*с\s+(.*)\s+г.\s*</td>') | |
date=patt2.findall(m1[0])[0] | |
patt3=re.compile(r'class="currencyrate_cell"[^>]*>([0-9.]+)</td>') | |
m2=patt3.findall(m1[0]) | |
print u"-----\nДоллар США {0}\nЕвро {1}\nРоссийский рубль {2}\n-----\nНБ КР {3}".format(m2[0], m2[1], m2[2], date) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment