Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.92 KB | None | 0 0
  1. <meta charset="UTF-8">
  2. <form action="giveapp.php" method="get">
  3. <input name="link" type="text" size="27">
  4. <input type="submit" value="Вытянуть данные">
  5. </form>
  6. <?php
  7. $linkforgame = $_GET['link'];
  8. function parse($w1, $w2, $w3){
  9.     $num0 = strpos($w1,$w2);
  10.     if($num0===false) return 0;
  11.    
  12.     $num = substr($w1,$num0).'  ';
  13.    
  14.      return strip_tags(substr($num,0,strpos($num,$w3)));
  15.    
  16.     //return substr($num,0,strpos($num,$w3));
  17. }
  18. function parseImg($w1, $w2,$w3){
  19.     $num0 = strpos($w1,$w2);
  20.    
  21.     if($num0===false) return '0sss';
  22.    
  23.     $num = substr($w1,$num0).'  ';
  24.     // $pattern = '/(w720-h310-rw" (?:srcset|data-ils))/';
  25.      // return strip_tags(substr($num,0,strpos($num,$w3)));
  26.       // echo $num;
  27.       // // $w3 = 'srcset';
  28.       // preg_match($pattern_, $num, $matches);
  29.       // // $w3 =
  30.       // print_r($matches);
  31.  
  32.      return substr($num,0,strpos($num,$w3));
  33.    
  34. }
  35. //для разных стран - разный header
  36. function cUrlGetData($url, $post_fields = null) {
  37.     $ch = curl_init();
  38.     $timeout = 5;
  39.     curl_setopt($ch, CURLOPT_URL, $url);
  40.     if ($post_fields && !empty($post_fields)) {
  41.         curl_setopt($ch, CURLOPT_POST, 1);
  42.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
  43.     }
  44.    
  45.     curl_setopt($ch, CURLOPT_HTTPHEADER,['Accept-Language: ru','Accept-Charset: utf-8']);
  46.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  47.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  48.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  49.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  50.    
  51.     $data = curl_exec($ch);
  52.     if (curl_errno($ch)) {
  53.         echo 'Error:' . curl_error($ch);
  54.     }
  55.     curl_close($ch);
  56.    
  57.     return $data;
  58. }
  59.  
  60. $html = cUrlGetData($linkforgame);
  61.  
  62.  // $subject = "иду есть завтра первое завтра второе";
  63.  // $pattern = '/(w720-h310-rw" (?:srcset|data-ils))/';
  64.  // $pattern = '/(завтра (?:первое|второе))/';
  65. // $subject = "defabc";
  66. // $pattern = '/^def/';
  67. // if(preg_match($pattern, $subject,$matches)){
  68.      // echo 'vrode, norm'.$matches[0];
  69. // }
  70.  
  71. //начало получения title
  72. $nameIn ='<title id="main-title">';
  73. $nameOut = '</title>';
  74. $nameGame = parse($html,$nameIn,$nameOut);
  75. $nameGame = 'Взлом '.mb_substr(str_replace("Приложения в Google Play",'', $nameGame),3,strlen($nameGame)).' скачать на Андроид и iOS</br>';
  76. echo $nameGame;
  77. //конец получения title
  78.  
  79. //регулярное /(rw" (?:первое|второе))/
  80. // $charset = mb_detect_encoding($nameGame);
  81.  
  82. // // // $nameGame = iconv($charset, "UTF-8", $nameGame);
  83. // // // $name = "Приложения в Google Play – Кубический Лабиринт Craft HD (3D)";//parse($html,$nameIn,$nameOut);
  84.   // // // strln($nameGame);
  85.  
  86. //начало получения description
  87. $descriptionIn = 'property="og:description" content="';
  88. $descriptionOut = '">';
  89. $descriptionGame = parse($html,$descriptionIn,$descriptionOut);
  90. $descriptionGame = str_replace($descriptionIn,'', $descriptionGame);
  91. echo $descriptionGame; 
  92. //конец получения description
  93.  
  94. // получение двух скринов НАЧАЛО!!
  95. $screenShotIn = 'data-screenshot-item-index="0">';//w1440-h620-rw 2x
  96. $screenshot1 = parseImg($html,$screenShotIn,'srcset').'/>';//=w1440-h620-rw 2x';
  97. $screenshot1 = str_replace('w720-h310','w1440-h620-rw',$screenshot1);//увеличить размер
  98. $screenshot1 = str_replace($screenShotIn,'',$screenshot1);//вырезаем тег ShotIN
  99. echo $screenshot1;
  100.  
  101. $screenShotIn = 'data-screenshot-item-index="1">';//w1440-h620-rw 2x
  102. $screenshot1 = parseImg($html,$screenShotIn,'srcset').'/>';//=w1440-h620-rw 2x';
  103. $screenshot1 = str_replace('w720-h310','w1440-h620-rw',$screenshot1);//увеличить размер
  104. $screenshot1 = str_replace($screenShotIn,'',$screenshot1);//вырезаем тег ShotIN
  105. echo $screenshot1;
  106. // получение двух скринов Конец!!
  107. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement