public function parse()
 {
     libxml_use_internal_errors(true);
     //
     //        $opts = array(
     //            'http'=>array(
     //                'charset'=>"utf-8",
     //            )
     //        );
     //        $context = stream_context_create($opts);
     $html = file_get_contents(DownloadUrlCreator::rbc($this->currencyType));
     $dom = new DOMDocument();
     $dom->loadHTML('<?xml encoding="UTF-8">' . $html);
     $table = $dom->getElementById('tableBody');
     $row = $table->getElementsByTagName('tr');
     foreach ($row as $currentRow) {
         $columns = $currentRow->getElementsByTagName('td');
         $bank = array();
         $bankId = 0;
         foreach ($columns as $column) {
             $class = $column->getAttribute('class');
             $bank[$class] = $column->nodeValue;
             switch ($class) {
                 case 'name':
                     $href = $column->getElementsByTagName('a')->item(0)->getAttribute('href');
                     $bankId = preg_replace("/[^0-9]/", '', $href);
                     if (!in_array($bankId, $this->banksId)) {
                         $this->banksId[] = $bankId;
                     }
                     break;
                 case 'info':
                     $bank['info'] = array();
                     $span = $column->getElementsByTagName('span');
                     foreach ($span as $info) {
                         $bank['info'][$info->getAttribute('id')] = $info->nodeValue;
                     }
                 default:
                     break;
             }
         }
         $this->banks[$bankId][$bank['sum']] = $bank;
     }
 }
 public function parse()
 {
     libxml_use_internal_errors(true);
     $opts = array('http' => array('charset' => "utf-8"));
     $context = stream_context_create($opts);
     $html = file_get_contents(DownloadUrlCreator::bankiRu(), false, $context);
     $dom = new DOMDocument();
     $dom->loadHTML($html);
     $tables = $dom->getElementsByTagName('table');
     foreach ($tables as $table) {
         if ($table->getAttribute('class') == 'standard-table standard-table--row-highlight') {
             $rateTable = $table;
         }
     }
     if ($rateTable) {
         $trTag = $rateTable->getElementsByTagName('tr');
         foreach ($trTag as $tr) {
             if ($bankId = $tr->getAttribute('data-currencies-row')) {
                 $tdTag = $tr->getElementsByTagName('td');
                 foreach ($tdTag as $td) {
                     if ($aTag = $td->getElementsByTagName('a')) {
                         foreach ($aTag as $a) {
                             if ($a->getAttribute('data-currencies-bank-name') == "") {
                                 $this->banks[$bankId]['href'] = $a->getAttribute('href');
                                 $this->banks[$bankId]['name'] = $a->nodeValue;
                                 continue;
                             }
                         }
                     }
                     if ($currency = $td->getAttribute('data-currencies-code')) {
                         $siteCurrency = array_search($currency, Yii::app()->params['sourceCurrency'][$this->sourceType]);
                         if ($sum = $td->getAttribute('data-currencies-rate-buy')) {
                             $this->banks[$bankId]['rates'][$siteCurrency]['buy'] = $sum;
                         } elseif ($sum = $td->getAttribute('data-currencies-rate-sell')) {
                             $this->banks[$bankId]['rates'][$siteCurrency]['sell'] = $sum;
                         }
                     }
                 }
             }
         }
     }
 }