Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> parsowanie php
qoryto
post
Post #1





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 1.07.2009
Skąd: Rzeszów

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


Witam, Mam otóż taki problem.
Kawałek kodu:
  1. $html= str_get_html($curlresult);
  2. $grab_urls = $html->find('a[class=s]');
  3. $grab_infos = $html->find('img[class=te]');
  4. $grab_vidtime = $html->find('span[class=d]');


Problem dotyczy $grab_infos. Pojaśnię:
Skrypt pobiera informacje ze strony w tym także obrazek. Wszystko działa fajnie, jednak jest problem przy pobraniu obrazka

fragment kodu z któej strony pobieram:

  1. <div class="video">
  2. <a href="/775361" title="XXX " >
  3. <img title="XXX " id="0775361" class="te lazy" data-src="http://img.ec.cdn.redtubefiles.com/_thumbs/0000775/0775361/0775361_015m.jpg" src="http://img01.redtubefiles.com/_thumbs/design/new-design/video-thumb-placeholder.gif" alt="Nubile Films - Gooey facial for petite teen " />
  4. </a>

Pobiera mi obrazek:

  1. http://img01.redtubefiles.com/_thumbs/design/new-design/video-thumb-placeholder.gif zamiast: <a href="http://img.ec.cdn.redtubefiles.com/_thumbs/0000775/0775361/0775361_015m.jpg" target="_blank">http://img.ec.cdn.redtubefiles.com/_thumbs...775361_015m.jpg</a>


Tutaj poprawiałem:

  1. $grab_infos = $html->find('img[class=te]');
  2. na:
  3. $grab_infos = $html->find('img[class=te lazy]');


i nadal nie działa. W jaki sposób pobrać str_get_html class="te lazy" data-src=" i dalszą część aby poprawną miniaturke mi skopiowało??

Pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
qoryto
post
Post #2





Grupa: Zarejestrowani
Postów: 63
Pomógł: 0
Dołączył: 1.07.2009
Skąd: Rzeszów

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


Cytat(aras785 @ 1.07.2014, 20:24:27 ) *
  1. <?php
  2. include('simple_html_dom.php');
  3.  
  4. $html = '<img title="Hot babysitter Melanie Rios" id="0622953" class="te lazy" data-src="http://img.l3.cdn.redtubefiles.com/_thumbs/0000622/0622953/0622953_009m.jpg" src="http://img01.redtubefiles.com/_thumbs/design/new-design/video-thumb-placeholder.gif" alt="Hot babysitter Melanie Rios" />';
  5.  
  6.  


Nie bardzo rozumie, jak to się ma do wszystkich miniatur filmików? ja podałem tylko przykład a reszte jak zrobic? (IMG:style_emoticons/default/snitch.gif)


tutaj pełna klasa:

  1. // Get Videos from RedTube.com ------------------------------
  2. case 'redtube.com':
  3. $page_number = 1;
  4. do {
  5. if ($page_number > $maxpages+1) {break;}
  6. if (($page_number > "1") AND ($showoutput == "yes")) {
  7. if ($grab_next_page) {$url = $grab_next_page;}
  8. $show_total_source++;
  9. if ($showoutput == "yes") {
  10. echo "<p align=\"left\"><i><b>[".$show_total_source."] Connecting ".$showfeedhost." page ".$page_number."...</b></i> [<a href=\"".$url."\" target=\"_blank\" title=\"Go to ".$url."\">Check Link</a>]<br></p>";
  11. flush_buffers();
  12. }
  13. }
  14. $curlresult = connectSource($url, $userAgent, $usefollow, $proxies, $proxysources, $feedhost, $family_filter);
  15. if (!$curlresult) {$feednotfound++; $notfoundstats[] = $url; break;}
  16. $html= str_get_html($curlresult);
  17. $grab_urls = $html->find('a[class=s]');
  18. $grab_infos = $html->find('img[class=te]');
  19. $grab_vidtime = $html->find('span[class=d]');
  20. $find_next = preg_match("/a id = \"navNext\" title = \"(.*)\" class = \"navigate\" href = \"(.*)\" onclick/Ui", $html, $next_page);
  21. $grab_next = $next_page[2];
  22. if ($grab_next) {$grab_next_page = $grab_next;} else {unset($grab_next_page);}
  23. $futuretime = 5; $pornmax = 1; $conta = 0; $grabbed_cp = 0;
  24. foreach ($grab_infos as $element) {
  25. if($pornmax > $maxvideos) {break;} else {
  26. $title = fixEncoding($element->title);
  27. $checklink = sanitize_title($title);
  28. $cl2 = $wpdb->get_var("SELECT post_name FROM $wpdb->posts WHERE post_name = '$checklink'");
  29. if ($cl2) {$conta++; continue;}
  30. $thumbnail = $element->src;
  31. $vidcod = $element->id;
  32. if (!$vidcod) {$conta++; continue;}
  33. $checkcod = $wpdb->get_var("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key= 'mvb_vid_code' AND meta_value = '$vidcod'");
  34. if ($checkcod) {$conta++; continue;}
  35. $description = "";
  36. $keywords = preg_replace('#[0-9,.?$@!]#i','',$title);
  37. $keywords = fixpornkeywords($keywords);
  38. $keywords = fixEncoding($keywords);
  39. if ($checktitle == "yes") {if (search_blocked_tags(strtolower($title), $blocktags)) {$conta++; continue;}}
  40. if ($checkdesc == "yes"){if (search_blocked_tags(strtolower($description), $blocktags)) {$conta++; continue;}}
  41. if ($checktags == "yes"){if (search_blocked_tags(strtolower($keywords), $blocktags)) {$conta++; continue;}}
  42. $postcontent = player_redtube($vidcod,$pwsize,$phsize);
  43. $redtube++;
  44. $mvbstats['RedTube'] = $redtube;
  45. $vidurl_original = $grab_urls[$conta]->href;
  46. if (!preg_match("/http/i", $vidurl_original)) {
  47. $vidurl_original = "http://www.redtube.com".$vidurl_original."";
  48. }
  49. $vidtime = $grab_vidtime[$conta]->plaintext;
  50. savepost($category, $keywords, $thumbnail, $description, $postcontent, $poststatus, $title, $commentstatus, $pingstatus, $feedhost, $vidcod, $postauthor, $futuretime, $vidurl_original, $grab_comments, $max_comments, $aprove_comments, $vidtime);
  51. $pornmax++; $conta++; $ptotaladded++; $grabbed++; $grabbed_cp++; $futuretime = $futuretime + $scheduletime;
  52. if ($showoutput == "yes") {
  53. echo "<p align=\"left\"><i><font color=\"green\">Video added:</font> ".$title." <font color=\"green\">(".$poststatus.")</font></i><br></p>";
  54. flush_buffers();
  55. }
  56. $grab_more = $maxvideos-$grabbed;
  57. if ($grab_more == "0") {break;}
  58. }
  59. }
  60. $html->clear();
  61. unset($html);
  62. if (($grabbed_cp == "0") AND ($showoutput == "yes")) { echo "<p align=\"left\"><i>There is no new videos in this page.</i><br></p>"; flush_buffers();}
  63. $page_number++;
  64. if (!$grab_next_page) {break;}
  65. } while (($grab_more > "0") OR ($grabbed == "0"));
  66. break;


Ten post edytował qoryto 1.07.2014, 19:35:28
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 16.10.2025 - 21:19