Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <meta charset="UTF-8">
- <form action="giveapp.php" method="get">
- <input name="link" type="text" size="27">
- <input type="submit" value="Вытянуть данные">
- </form>
- <?php
- $linkforgame = $_GET['link'];
- function parse($w1, $w2, $w3){
- $num0 = strpos($w1,$w2);
- if($num0===false) return 0;
- $num = substr($w1,$num0).' ';
- return strip_tags(substr($num,0,strpos($num,$w3)));
- //return substr($num,0,strpos($num,$w3));
- }
- function parseImg($w1, $w2,$w3){
- $num0 = strpos($w1,$w2);
- if($num0===false) return '0sss';
- $num = substr($w1,$num0).' ';
- // $pattern = '/(w720-h310-rw" (?:srcset|data-ils))/';
- // return strip_tags(substr($num,0,strpos($num,$w3)));
- // echo $num;
- // // $w3 = 'srcset';
- // preg_match($pattern_, $num, $matches);
- // // $w3 =
- // print_r($matches);
- return substr($num,0,strpos($num,$w3));
- }
- //для разных стран - разный header
- function cUrlGetData($url, $post_fields = null) {
- $ch = curl_init();
- $timeout = 5;
- curl_setopt($ch, CURLOPT_URL, $url);
- if ($post_fields && !empty($post_fields)) {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
- }
- curl_setopt($ch, CURLOPT_HTTPHEADER,['Accept-Language: ru','Accept-Charset: utf-8']);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
- $data = curl_exec($ch);
- if (curl_errno($ch)) {
- echo 'Error:' . curl_error($ch);
- }
- curl_close($ch);
- return $data;
- }
- $html = cUrlGetData($linkforgame);
- // $subject = "иду есть завтра первое завтра второе";
- // $pattern = '/(w720-h310-rw" (?:srcset|data-ils))/';
- // $pattern = '/(завтра (?:первое|второе))/';
- // $subject = "defabc";
- // $pattern = '/^def/';
- // if(preg_match($pattern, $subject,$matches)){
- // echo 'vrode, norm'.$matches[0];
- // }
- //начало получения title
- $nameIn ='<title id="main-title">';
- $nameOut = '</title>';
- $nameGame = parse($html,$nameIn,$nameOut);
- $nameGame = 'Взлом '.mb_substr(str_replace("Приложения в Google Play",'', $nameGame),3,strlen($nameGame)).' скачать на Андроид и iOS</br>';
- echo $nameGame;
- //конец получения title
- //регулярное /(rw" (?:первое|второе))/
- // $charset = mb_detect_encoding($nameGame);
- // // // $nameGame = iconv($charset, "UTF-8", $nameGame);
- // // // $name = "Приложения в Google Play – Кубический Лабиринт Craft HD (3D)";//parse($html,$nameIn,$nameOut);
- // // // strln($nameGame);
- //начало получения description
- $descriptionIn = 'property="og:description" content="';
- $descriptionOut = '">';
- $descriptionGame = parse($html,$descriptionIn,$descriptionOut);
- $descriptionGame = str_replace($descriptionIn,'', $descriptionGame);
- echo $descriptionGame;
- //конец получения description
- // получение двух скринов НАЧАЛО!!
- $screenShotIn = 'data-screenshot-item-index="0">';//w1440-h620-rw 2x
- $screenshot1 = parseImg($html,$screenShotIn,'srcset').'/>';//=w1440-h620-rw 2x';
- $screenshot1 = str_replace('w720-h310','w1440-h620-rw',$screenshot1);//увеличить размер
- $screenshot1 = str_replace($screenShotIn,'',$screenshot1);//вырезаем тег ShotIN
- echo $screenshot1;
- $screenShotIn = 'data-screenshot-item-index="1">';//w1440-h620-rw 2x
- $screenshot1 = parseImg($html,$screenShotIn,'srcset').'/>';//=w1440-h620-rw 2x';
- $screenshot1 = str_replace('w720-h310','w1440-h620-rw',$screenshot1);//увеличить размер
- $screenshot1 = str_replace($screenShotIn,'',$screenshot1);//вырезаем тег ShotIN
- echo $screenshot1;
- // получение двух скринов Конец!!
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement