-
-
Save bruna17/4e6ce89de89db1b1d474899f4385ddb8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header('Content-type: text/html; charset=UTF-8'); | |
class Pars{ | |
public static function getContent($url=false){ | |
//echo $url."<br>Новая"; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL,$url); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);//CURLOPT_CONNECTTIMEOUT_MS | |
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 350); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//если посставить 0 или закоментить то будут заголовки перед редиректом | |
$arr = array( | |
'Upgrade-Insecure-Request: 1', | |
'X-DevTools-Emulate-Network-Conditions-Client-Id: 2d796fbb-8658-4ef9-86a0-d8536fa71efb', | |
'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36', | |
'Accept: text/html,application/xhtml xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8', | |
'Accept-Encoding: gzip, deflate, br', | |
'Accept-Language: ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7', | |
'Cookie: __io=ae396f3bb.e5af6739b_1540396245237; _ym_uid=1540396245327364325; _ym_d=1540396245; _ga=GA1.2.1053507404.1540396246; __io_first_source=google.ru; __io_r=https%3A%2F%2Fzen.yandex.com; DDOSEXPERT_COM_V3=dfe32f64698943580c7f4f5996c5177d; PHPSESSID=8k577tgopecj4pbi3fd31j6lt6; _gid=GA1.2.504479266.1542032063; _ym_isad=2; __io_unique_12027=12; __io_lv=1542035732710; last_visit=1542025339663::1542036139663; tmr_detect=0|1542036142293;', | |
'Pragma: akamai-x-cache-on, akamai-x-cache-remote-on, akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-extracted-values, akamai-x-get-ssl-client-session-id, akamai-x-get-true-cache-key, akamai-x-serial-no, akamai-x-get-request-id,akamai-x-get-nonces,akamai-x-get-client-ip,akamai-x-feo-trace;', | |
'Referer: https://www.igromania.ru/article/30505/Metro_Exodus_Ob_oruzhii_narrative_i_buduschem_studii.html' | |
); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $arr); | |
curl_setopt($ch,CURLOPT_ENCODING, ''); | |
curl_setopt( $ch, CURLOPT_COOKIESESSION, true ); | |
$cc = curl_exec($ch); | |
curl_close($ch); | |
return $cc; | |
} | |
public static function getPars($regulat,$body,$one,$two){ | |
preg_match_all($regulat, $body, $matches); | |
return $matches[$one][$two]; | |
} | |
public static function getParss($regulat,$body){ | |
//echo $body; | |
preg_match_all($regulat, $body, $matches); | |
//print_r($matches); | |
return $matches; | |
} | |
} | |
//<[^>]*> | |
//$pars = Pars::getContent("https://www.igromania.ru/rss/rss_articles.xml"); | |
//$urlLink = Pars::getPars('~\<link\>(.*?)\<\/link\>~',$pars,"0","1"); | |
//echo $urlLink."<br>"; | |
$pars1 = Pars::getContent("https://www.igromania.ru/article/30505/Metro_Exodus_Ob_oruzhii_narrative_i_buduschem_studii.html"); | |
echo $pars1; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment