Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 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.      echo strpos($num,$w3);
  16.     //return substr($num,0,strpos($num,$w3));
  17. }
  18. //для разных стран - разный header
  19. function cUrlGetData($url, $post_fields = null) {
  20.     $ch = curl_init();
  21.     $timeout = 5;
  22.     curl_setopt($ch, CURLOPT_URL, $url);
  23.     if ($post_fields && !empty($post_fields)) {
  24.         curl_setopt($ch, CURLOPT_POST, 1);
  25.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
  26.     }
  27.    
  28.     curl_setopt($ch, CURLOPT_HTTPHEADER,['Accept-Language: ru','Accept-Charset: utf-8']);
  29.     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  30.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  31.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  32.     curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  33.    
  34.     $data = curl_exec($ch);
  35.     if (curl_errno($ch)) {
  36.         echo 'Error:' . curl_error($ch);
  37.     }
  38.     curl_close($ch);
  39.    
  40.     return $data;
  41. }
  42.  
  43. $html = cUrlGetData($linkforgame);
  44.  
  45. // $subject = "иду есть завтра первое завтра второе";
  46. // $pattern = '/(завтра" (?:первое|второе))/';
  47. $subject = "defabc";
  48. $pattern = '/^def/';
  49. if(preg_match($pattern, $subject)){
  50.     echo 'vrode, norm';
  51. }
  52.  
  53. //начало получения title
  54. // $nameIn ='<title id="main-title">';
  55. // $nameOut = '</title>';
  56. // $nameGame = parse($html,$nameIn,$nameOut);
  57. // $nameGame = 'Взлом '.mb_substr(str_replace("Приложения в Google Play",'', $nameGame),3,strlen($nameGame)).' скачать на Андроид и iOS</br>';
  58. // echo $nameGame;
  59. //конец получения title
  60.  
  61. //регулярное /(rw" (?:первое|второе))/
  62. // $charset = mb_detect_encoding($nameGame);
  63.  
  64. // // // $nameGame = iconv($charset, "UTF-8", $nameGame);
  65. // // // $name = "Приложения в Google Play – Кубический Лабиринт Craft HD (3D)";//parse($html,$nameIn,$nameOut);
  66.   // // // strln($nameGame);
  67.  
  68. // $descriptionIn = 'property="og:description" content="';
  69. // $descriptionOut = '">';
  70. // $descriptionGame = parse($html,$descriptionIn,$descriptionOut);
  71. // $descriptionGame = str_replace($descriptionIn,'', $descriptionGame);
  72. // echo $descriptionGame;
  73.  
  74.  
  75.  
  76. // $screenShotIn = 'data-screenshot-item-index="4">';//w1440-h620-rw 2x
  77. // $screenshotOut = ' srcset'; //или data-ils
  78. // $screenshot1 = parse($html,$screenShotIn,$screenshotOut).'/>';//=w1440-h620-rw 2x';
  79. // $screenshot1 = str_replace('w720-h310','w1440-h620-rw',$screenshot1);//увеличить размер
  80. // echo $screenshot1;
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement