Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Problem z simple_html_dom
unw
post 14.11.2017, 16:26:53
Post #1





Grupa: Zarejestrowani
Postów: 44
Pomógł: 0
Dołączył: 12.06.2008

Ostrzeżenie: (0%)
-----


Witam, mam taki skrypt;

  1. require_once 'simple_html_dom.php';
  2. $url = 'https://www.pornhub.com/video/search?search=teen';
  3. $userAgent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6';
  4.  
  5. $ch = curl_init();
  6. curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
  7. curl_setopt($ch, CURLOPT_URL,$url);
  8. curl_setopt($ch, CURLOPT_FAILONERROR, true);
  9. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  10. curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  11. curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
  12. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  13. curl_setopt($ch, CURLOPT_TIMEOUT, 50);
  14. $str= curl_exec($ch);
  15. if (!$str)
  16. {
  17. echo "<br />cURL error number:" .curl_errno($ch);
  18. echo "<br />cURL error:" . curl_error($ch);
  19. }
  20. $html = str_get_html($str);
  21.  
  22.  
  23.  
  24. $title = array();
  25.  
  26. foreach($html->find('div.phimage') as $titl) {
  27.  
  28. $title[] = $titl->find('a', 0)->innertext;
  29.  
  30. }
  31.  
  32.  
  33. print_r($title);



Chcę pobrać tytuł, jednak wywala mi:
  1. Array
  2. (
  3. [0] => <div class="img videoPreviewBg">


i tak dalej i tak dalej.
Chciałbym pobrać tytuły wszystkich filmów.
Czy jest możliwosć aby w jednej tablicy mieć wszystko info czyli np:

Tytuł, Adres filmu, Obrazek?

jeżeli tak to jak?

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 25.04.2024 - 08:41