Skip to content

Instantly share code, notes, and snippets.

@Fak3
Created March 16, 2016 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fak3/4ec8fabab0f97fe2bfd8 to your computer and use it in GitHub Desktop.
Save Fak3/4ec8fabab0f97fe2bfd8 to your computer and use it in GitHub Desktop.
cbr_soap.py
#!/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