Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. header('Content-type: text/html; charset=UTF-8');
  5.  
  6.  
  7. class Pars{
  8.  
  9.     public static function getContent($url=false){
  10.  
  11.         //echo $url."<br>Новая";
  12.         $ch = curl_init();
  13.         curl_setopt($ch, CURLOPT_URL,$url);
  14.        
  15.         curl_setopt($ch, CURLOPT_HEADER, 0);
  16.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//CURLOPT_CONNECTTIMEOUT_MS
  17.         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 350);
  18.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//если посставить 0 или закоментить  то будут заголовки перед редиректом
  19.         curl_setopt($ch,CURLOPT_ENCODING, '');
  20.         curl_setopt( $ch, CURLOPT_COOKIESESSION, true );
  21.         curl_setopt($ch, CURLOPT_HTTPHEADER, array("Cookie: DDOSEXPERT_COM_V3=ca0a834787bbffd5f900af68529785c2"));
  22.        
  23.         $cc = curl_exec($ch);
  24.  
  25.         curl_close($ch);
  26.        
  27.         return $cc;
  28.  
  29.        
  30.     }
  31.  
  32.    public static function getPars($regulat,$body,$one,$two){
  33.         preg_match_all($regulat, $body, $matches);
  34.  
  35.         return $matches[$one][$two];
  36.  
  37.    }
  38.  
  39.    public static function getParss($regulat,$body){
  40.         //echo $body;
  41.         preg_match_all($regulat, $body, $matches);
  42.         //print_r($matches);
  43.         return  $matches;
  44.    }
  45.  
  46.    
  47.  
  48. }
  49.  
  50.  
  51.  
  52.  
  53. //<[^>]*>
  54.  
  55. //$pars = Pars::getContent("https://www.igromania.ru/rss/rss_articles.xml");
  56.  
  57. //$urlLink = Pars::getPars('~\<link\>(.*?)\<\/link\>~',$pars,"0","1");
  58. //echo $urlLink."<br>";
  59.  
  60. $pars1 = Pars::getContent("https://www.igromania.ru/article/30505/Metro_Exodus_Ob_oruzhii_narrative_i_buduschem_studii.html");
  61. echo $pars1;
  62.    
  63. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement