Package stocks3 :: Package parsers :: Module cbr
[hide private]
[frames] | no frames]

Source Code for Module stocks3.parsers.cbr

 1  # -*- coding: utf-8 -*- 
 2   
 3  u""" 
 4  Парсер для cbr.ru. 
 5  """ 
 6   
 7  __author__ = "Zasimov Alexey" 
 8  __email__ = "zasimov-a@yandex-team.ru" 
 9   
10   
11  from stocks3.parsers.xml import XMLParser 
12  from stocks3.core.factories import parsers 
13   
14   
15 -class CbrRuParser(XMLParser):
16 - def parse(self, place):
17 XMLParser.parse(self, place) 18 date = self.strpdate(self.dataRoot.get('Date')) 19 for item in self.findall('Valute'): 20 sourceQuoteId = item.findtext('CharCode') 21 value = item.findtext('Value').replace(',', '.') 22 price = self.makePrice(sourceQuoteId, date, value) 23 if price: 24 yield price
25 26 parsers.register("stocks3.parsers.CbrRu", CbrRuParser) 27