Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1. <style type="text/css">
  2.     .question__tags{
  3.         display: flex;
  4.     }
  5.     .question__attrs{
  6.         display: flex;
  7.     }
  8. </style>
  9. <?php
  10. require "phpQuery-onefile.php";
  11.  
  12. function get_data($url)
  13. {
  14. $ch = curl_init();
  15. $timeout = 5;
  16. curl_setopt($ch,CURLOPT_URL,$url);
  17. curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
  18. curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
  19. curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:7.0.1) Gecko/20100101 Firefox/7.0.1');
  20. $data = curl_exec($ch);
  21. curl_close($ch);
  22. return $data;
  23. }
  24.  
  25. $url = 'https://toster.ru/';
  26.  
  27. // $pattern = '#<table class="kurs_table_small.+?</table>#s';
  28. // preg_match($pattern, $file, $matches);
  29. // print_r($matches);
  30.  
  31. $doc = phpQuery::newDocument(get_data($url));
  32. $tbl = $doc->find('.content-list');
  33. foreach ($tbl->find('.content-list__item') as $tr) {
  34.     $pq = pq($tr);
  35.     if(strlen($pq->find(".question__title")) > 7){
  36.     echo "-----------------------------------------------------------------------------------------------------------------------";
  37.     echo $pq->find(".question__tags");
  38.     echo $pq->find(".question__title");
  39.     echo $pq->find(".question__attrs");
  40.     echo "-----------------------------------------------------------------------------------------------------------------------";
  41.     }
  42. }
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement