Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. class Pars{
  2.  
  3.     public static function getContent($url=false){
  4.  
  5.         //echo $url."<br>Новая";
  6.         $ch = curl_init();
  7.         curl_setopt($ch, CURLOPT_URL,$url);
  8.        
  9.         curl_setopt($ch, CURLOPT_HEADER, 0);
  10.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//CURLOPT_CONNECTTIMEOUT_MS
  11.  
  12.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 350);
  13.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//если посставить 0 или закоментить  то будут заголовки перед редиректом
  14.        
  15.        
  16.  
  17.        
  18.  
  19.         $cc = curl_exec($ch);
  20.  
  21.         curl_close($ch);
  22.        
  23.         return $cc;
  24.  
  25.        
  26.     }
  27.  
  28.    
  29.  
  30.    public static function getParss($regulat,$body){
  31.         //echo $body;
  32.         preg_match_all($regulat, $body, $matches);
  33.         //print_r($matches);
  34.         return  $matches;
  35.    }
  36.  
  37.    
  38.  
  39. }
  40.  
  41.  
  42.  
  43. $parsRss = Pars::getContent("https://shazoo.ru/feed/rss");
  44.  
  45. $xmlLink = Pars::getParss('~<h3><a.+?href="(.+?)".+?<\/h3>~su',$parsRss);
  46. print_r($xmlLink)."<br>";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement