Created
March 16, 2016 16:18
-
-
Save Fak3/4ec8fabab0f97fe2bfd8 to your computer and use it in GitHub Desktop.
cbr_soap.py
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 -*- | |
from __future__ import unicode_literals | |
from __future__ import print_function | |
from datetime import datetime, timedelta | |
from dateutil.parser import parse as parse_dt | |
from suds.client import Client | |
from suds.xsd.doctor import Import, ImportDoctor | |
cbr_namespace = "http://web.cbr.ru/" | |
url = "http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?wsdl" | |
imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') | |
imp.filter.add(cbr_namespace) | |
client = Client(url, doctor=ImportDoctor(imp)) | |
start = datetime.now() - timedelta(days=30) | |
end = datetime.now() | |
result = client.service.Ruonia(start, end) | |
for x in result.diffgram.Ruonia.ro: | |
print("Дата %s" % parse_dt(x.D0).strftime('%Y.%m.%d')) | |
print("Ставка, %s %%" % x.ruo) | |
print("Объем сделок %s млрд. руб\n" % x.vol) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment