Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Zamiana poczatku url na inny....
Randallmaster
post
Post #1





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

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


Witam serdecznie.. Napisałem taki skrypt:

  1. <?php
  2.  
  3. $curl = curl_init();
  4. curl_setopt ($curl, CURLOPT_URL, "http://praca.gazetapraca.pl/0,4050,,,1,20,-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>#", $result, $links))
  13. {
  14. foreach($links[0] as $link)
  15. {
  16. if(preg_match_all("#<strong>(.*?)</strong>#", $result, $links))
  17. {
  18. foreach($links[0] as $link)
  19. {
  20. echo $link."<br />";}
  21. }
  22. }
  23.  
  24. }
  25.  
  26. ?>


Wyniki działania:
http://www.pracujkalisz.pl/dane.php

jedynie co źle wychodzi to link:

http://www.pracujkalisz.pl/200,4001,,76866...r+Naczelny.html

a powinno być tak:

http://praca.gazetapraca.pl/200,4001,,7686...r+Naczelny.html

jak zamienić początki linku??
to:
http://www.pracujkalisz.pl/
na:
http://praca.gazetapraca.pl/

prosze 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%)
-----


To jest kod stworzony przez jednego z użytkowników:

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



a to jest mój


  1. <?php
  2.  
  3. $curl = curl_init();
  4. curl_setopt ($curl, CURLOPT_URL, "http://praca.gazetapraca.pl/0,4050,,,1,20,-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>#", $result, $links))
  13. {
  14. foreach($links[0] as $link)
  15. {
  16. if(preg_match_all("#<strong>(.*?)</strong>#", $result, $links))
  17. {
  18. foreach($links[0] as $link)
  19. {
  20. echo $link."<br />";}
  21. }
  22. }
  23.  
  24. }
  25.  
  26. ?>



Fakt faktem robiłem go sam przez przerabianie innych skryptów ale zrobiłem go sam... dziękuję za pomoc (IMG:style_emoticons/default/smile.gif)
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: 5.10.2025 - 03:49