Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require "phpQuery-onefile.php";
- function get_data($url)
- {
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch,CURLOPT_URL,$url);
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
- curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1');
- $data = curl_exec($ch);
- curl_close($ch);
- return $data;
- }
- $url = 'https://bankir.ru/kurs/';
- // $pattern = '#<table class="kurs_table_small.+?</table>#s';
- // preg_match($pattern, $file, $matches);
- // print_r($matches);
- $doc = phpQuery::newDocument(get_data($url));
- $tbl = $doc->find('.kurs_table_small > tbody');
- $z = 0;
- foreach ($tbl->find('tr') as $tr) {
- $pq = pq($tr);
- $img = $pq->find("img")->attr("src");
- if ($z == 0){
- echo $pq->text()."<br />";
- }
- else{
- echo $pq->text()."<img src='https://bankir.ru{$img}'>"."<br/>" ;
- }
- $z++;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement