Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Pobieranie tekstu i url z innej strony
Randallmaster
post
Post #1





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


Witam serdecznie,

Tworzę portal dla swojego miasta:

www.pracujkalisz.pl

i chciałbym dodać na swojej stronie ogłoszenia z innych stron www np:

http://praca.gazetapraca.pl/0,4050,,,1,10,...,,,,,,,133.html

są tam ogłoszenia a ja chce tylko np.
Kierownik Filii z linkiem do strony....

niestety siedziałem bardzo długi okres nad zrobieniem tego i po prostu mnie to przerosło, nie piszcie poczytaj tam, poszukaj w google bo to robiłem... Potrafię napisać kod który wyświetli daną stronę ale zupełnie nie wiem jak ma wygenerować tą część strony... próbowałem preg_match i takie inne nic nie wychodzi proszę o pomoc....
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Randallmaster
post
Post #2





Grupa: Zarejestrowani
Postów: 677
Pomógł: 11
Dołączył: 18.11.2009

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


do notatnika wrzuciłem tylko to:

  1.  
  2. <?php
  3. $string = file_get_contents('http://praca.gazetapraca.pl/0,4050,,,1,10,-postDate,,,,,,Kalisz,,,0,,,,,,,,133.html');
  4. $tekst = "<body onload><table><tr><td>ala ma kota</td></tr></table></body>";
  5.  
  6. $result = preg_match_all('/<div class="c0">(.*?)<\/div>/s', $string, $match);
  7.  
  8. $links = array();
  9. foreach($match AS $value)
  10. {
  11. foreach($value AS $val)
  12. {
  13. $result2 = preg_match('/<strong>(.*?)<\/strong>/s', $val, $match2);
  14. $links[] = $match2[1];
  15. }
  16.  
  17. }
  18. $links = array_filter($links);
  19. print_r($links);
  20.  
  21. ?>


i zapisałem pod nazwą: dane.php

a mógłbyś mi twój plik przesłać na: randall.kamil@gmail.com?(IMG:style_emoticons/default/questionmark.gif)


Stworzyłem kod który mi wyświetla dany div...

ale jak zrobić żeby wyświetlał <strong>?

  1. <?php
  2.  
  3. $curl = curl_init();
  4. curl_setopt ($curl, CURLOPT_URL, "http://praca.gazetapraca.pl/0,4050,,,1,10,-postDate,,,,,,Kalisz,,,0,,,,,,,,133.html");
  5. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  6.  
  7. $result = curl_exec ($curl);
  8. curl_close ($curl);
  9.  
  10.  
  11. //links
  12. if(preg_match_all("#<div class=\"c0\">(.*?)</div>#is", $result, $links))
  13. {
  14. foreach($links[0] as $link)
  15. {
  16. echo $link."<br />";
  17. }
  18. }
  19.  
  20. ?>


Stworzyłem kod który mi wyświetla dany div...

ale jak zrobić żeby wyświetlał <strong>?

  1. <?php
  2.  
  3. $curl = curl_init();
  4. curl_setopt ($curl, CURLOPT_URL, "http://praca.gazetapraca.pl/0,4050,,,1,10,-postDate,,,,,,Kalisz,,,0,,,,,,,,133.html");
  5. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  6.  
  7. $result = curl_exec ($curl);
  8. curl_close ($curl);
  9.  
  10.  
  11. //links
  12. if(preg_match_all("#<div class=\"c0\">(.*?)</div>#is", $result, $links))
  13. {
  14. foreach($links[0] as $link)
  15. {
  16. echo $link."<br />";
  17. }
  18. }
  19.  
  20. ?>
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: 26.12.2025 - 08:18