Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.86 KB | None | 0 0
  1. <?
  2. error_reporting(E_ALL | E_STRICT);
  3. ini_set('display_errors', 'On');
  4. require_once 'simple_html_dom.php'; // библиотека для парсинга
  5. require_once 'safemysql.class.php';
  6. require($_SERVER['DOCUMENT_ROOT'].'/wp-load.php');
  7. ?>
  8.  
  9.  
  10. <?php
  11. $host="localhost";/*Имя сервера*/
  12. $user="mihanspk_test9";/*Имя пользователя*/
  13. $password="qwerty3412";/*Пароль пользователя*/
  14. $db="mihanspk_test9";/*Имя базы данных*/
  15. mysql_connect($host, $user, $password); /*Подключение к серверу*/
  16. mysql_select_db($db) or die("Нет соединения с БД".mysql_error());
  17. ?>
  18.  
  19. <?
  20. $file = 'ssilki.txt';
  21. // Открываем файл для получения существующего содержимого
  22. $current = file_get_contents($file);
  23.  
  24. ?>
  25.     <form action="" class="" method="post">
  26.         <textarea name="text_url" style="width:50%; height:400px;"><?=$current;?></textarea><br/>
  27.         <input type="submit" value="pars!"/>
  28.     </form>
  29.    
  30. <?php
  31. if(isset($_POST['text_url'])) {
  32.     $zapros_full=$_POST['text_url'];
  33.     $zapross = explode("\r\n", $_POST['text_url']);
  34.    
  35.  
  36.  
  37.  
  38. $current = $zapros_full;
  39. // Пишем содержимое обратно в файл
  40. file_put_contents($file, $current);
  41.    
  42.    
  43.    
  44.     foreach($zapross as $zapross_iteam){?>
  45.     <?
  46.         echo "<h2>";
  47.         echo $zapross_iteam;
  48.         echo "</h2>";
  49.         $html = file_get_html($zapross_iteam);
  50.     if($html->find('table.building-pages', 0)){
  51.         echo "<h2>SALE</h2>";  
  52.         foreach ($html->find('table.building-pages', 0)->find('tbody tr') as $Sales) {
  53.             $address=$Sales->find('.address a', 0)->plaintext;
  54.             $price=$Sales->find('.price', 0)->plaintext;
  55.             $Beds=$Sales->find('td', 2)->plaintext;
  56.             $Baths=$Sales->find('td', 3)->plaintext;
  57.             $ft=$Sales->find('td', 4)->plaintext;
  58.            
  59.                
  60.             if($address){
  61.                 $result2 = "INSERT INTO Sales(address,price,Beds,Baths,ft,page) VALUES ('$address','$price','$Beds','$Baths','$ft','$zapross_iteam')";
  62.                 mysql_query($result2);
  63.                 echo $address; echo $price; echo $Beds; echo $address; echo $Baths; echo $ft; echo "<br/>";
  64.             }
  65.         }
  66.     }
  67.         sleep(3);
  68.     if($html->find('table.building-pages', 1)){
  69.         echo "<h2>RENTAL</h2>";
  70.         foreach ($html->find('table.building-pages', 1)->find('tbody tr') as $Sales) {
  71.             $address=$Sales->find('.address a', 0)->plaintext;
  72.             $price=$Sales->find('.price', 0)->plaintext;
  73.             $Beds=$Sales->find('td', 2)->plaintext;
  74.             $Baths=$Sales->find('td', 3)->plaintext;
  75.             $ft=$Sales->find('td', 4)->plaintext;
  76.            
  77.                
  78.             if($address){
  79.                 $result2 = "INSERT INTO Rentals(address,price,Beds,Baths,ft,page) VALUES ('$address','$price','$Beds','$Baths','$ft','$zapross_iteam')";
  80.                 mysql_query($result2);
  81.                 echo $address; echo $price; echo $Beds; echo $address; echo $Baths; echo $ft; echo "<br/>";
  82.             }
  83.         }
  84.     }      
  85.         sleep(3);
  86.        
  87. ?>
  88.    
  89.    
  90.     <?sleep(3);?>
  91.     <?}?>
  92. <?}
  93. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement