Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wyświetlanie czesci innej strony., Wyswietlic statystyki z innej strony...
Macok
post
Post #1





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


W jaki sposób wyswietlic na stronie kod źródłowy innej strony?

Chodzi mi o wyświetlenie tego co widzimy jak klikniemy prawym przyciskiem myszy na stronie a potem na pokaż źródło.

Ten post edytował Macok 10.10.2006, 15:14:22
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 17)
skowron-line
post
Post #2





Grupa: Zarejestrowani
Postów: 4 340
Pomógł: 542
Dołączył: 15.01.2006
Skąd: Olsztyn/Warszawa

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


file_get_contents
Go to the top of the page
+Quote Post
dr_bonzo
post
Post #3





Grupa: Przyjaciele php.pl
Postów: 5 724
Pomógł: 259
Dołączył: 13.04.2004
Skąd: N/A

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


i wyswietl potem po przepuszczeniu przez htmlspecialchars()
Go to the top of the page
+Quote Post
Macok
post
Post #4





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


I jeszcze jedno!
Co zrobić zeby skrypt nie wyswietlal calego kodu, tylko np. od wyrażenia: "poziom postaci" do "profesja postaci"?
Go to the top of the page
+Quote Post
bim2
post
Post #5





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


aaa już wiem co kombinujesz (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) Tibia lub cóś innego, to nie prościej walnąc prega i w zmiennych mieć wszystkie dane?
Go to the top of the page
+Quote Post
Macok
post
Post #6





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


No zeczywiscie mnie rozszyfrowales (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) (chce wyswietlic poziom danej postaci)
Ale napiszcie dokladniej jak by to zrobic (IMG:http://forum.php.pl/style_emoticons/default/snitch.gif)
Cytat
walnąc prega
Chodzi o preg_replace?

Ten post edytował Macok 10.10.2006, 14:52:37
Go to the top of the page
+Quote Post
bim2
post
Post #7





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


tak (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) zwykle nie zmienia sie layout wiec posluzy ci i bedziesz mogl wlasna tabelke zrobic. walnija jakos tak: (zobacz w zrodlo) "!<td>Lvl:</td><td>([0-9])</td>!e", "$lvl = $1"
Go to the top of the page
+Quote Post
bim2
post
Post #8





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


bo dajesz htmlspecialchar wczesniej i wtedy zamaist < amsz &gt; chyba lub &lt;
Go to the top of the page
+Quote Post
Macok
post
Post #9





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


Mam taki kod i dziala (";" i "players" zamienia sie na "$lvl = $1"):
  1. <?
  2. // bbcode
  3. Function bbcode($str){
  4.  
  5. $str=str_replace(";", "$lvl = $1", $str);
  6. $str=str_replace("players", "$lvl = $1", $str);
  7.  
  8. return $str;}
  9.  
  10.  
  11.  
  12. $Code=file_get_contents('http://www.tibia.com/'); 
  13. $Code=nl2br(htmlspecialchars($Code)); 
  14.  
  15. echo bbcode($Code);
  16.  
  17.  
  18. ?>
Ale to juz nie dziala:
  1. <?php
  2. // bbcode
  3. Function bbcode($str){
  4. $str=str_replace(";([0-9])players", "$lvl = $1", $str);
  5.  
  6. $str=nl2br($str);
  7.  
  8.  
  9. $str=nl2br($str);
  10.  
  11. return $str;}
  12.  
  13.  
  14. $Code=file_get_contents('http://www.tibia.com/'); 
  15. $Code=nl2br(htmlspecialchars($Code)); 
  16.  
  17. echo bbcode($Code);
  18.  
  19.  
  20. ?>
Co poprawic w tym kodzie?

Ten post edytował Macok 10.10.2006, 16:56:34
Go to the top of the page
+Quote Post
bim2
post
Post #10





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


Strreplace nie obsluguje wyrazen regularnych
$str=preg_replace("!;([0-9])players!ei", "$lvl = $1", $str);
i teraz w zmiennej $lvl amsz te players
Go to the top of the page
+Quote Post
Macok
post
Post #11





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


1. A co zrobic zeby wyswietlilo nie tylko liczby, ale tez tekst?
2. Dlaczego skrypt nie dziala jesli musi wyswietlic liczby pomiedzy znakami ">" itp.?

Ten post edytował Macok 10.10.2006, 18:09:51
Go to the top of the page
+Quote Post
bim2
post
Post #12





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


http://bedkowski.pl/a/php_regex/ poczytaj a zrozumiesz

Za pewien czas załącze class TibiaInfo która będzie pobierała dane o postaci useów online na danym świecie itd.

Ten post edytował bim2 10.10.2006, 18:16:13
Go to the top of the page
+Quote Post
Prph
post
Post #13





Grupa: Zarejestrowani
Postów: 338
Pomógł: 2
Dołączył: 4.03.2006
Skąd: Łódź

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


Tak w ogole, to warto zainteresowac sie Web Services, czyli uslugami oferowanymi przez inne serwery. Dla przykladu:

1. wywolujemy adres (poprzez sokety) strona.pl/pokaz_uzytkownika/12345/
2. strona.pl zwraca nam XMLa z danymi uzytkownika. Sam XML moze byc tzw. paczką - czyli moze zawierac takze pliki, np. graficzne.
3. Przetwarzamy XMLa u siebie w skrypcie i voila.

Jeden problem - to musi udostepniac serwer. Ale napisanie czegos takiego jest wrecz banalne, wiec czasem wystarczy przedstawic korzysci, jakie moze osiadnac dany "dostawca danych" (IMG:http://forum.php.pl/style_emoticons/default/winksmiley.jpg)

Adrian.
Go to the top of the page
+Quote Post
bim2
post
Post #14





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


wydaje mi sie że Cip się nie zgodzi (Cip = firma tibi) ikm się nie chce (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) Maja juz dużo roboty, chociaż było by to coś super
Go to the top of the page
+Quote Post
Macok
post
Post #15





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


Pogmatwałem troche w tym kodzie no i prawie sie udalo (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) Teraz jezeli wpisze zamiast "$zmienna" np. "zmienna" to zamiast poziomu postaci wyswietli mi sie napis zmienna. Problem w tym ze kiedy wpisze tam właśnie "$zmienna" to cos jest nie tak. Jak widac na koncu dalem: "echo $zmienna; " wiec powinien sie wyswietlic poziom postaci. Niestety nie wyswietla sie nic. Dlaczego??
  1. <?
  2. // bbcode
  3. Function bbcode($str){
  4.  
  5.  
  6. $str=preg_replace("!:&lt;/TD&gt;&lt;TD&gt;!", "X", $str);
  7.  
  8.  
  9.  
  10. $str=preg_replace("!&lt;/TD&gt;&lt;/TR&gt;&lt;TR BGCOLOR=#F1E0C6&gt;&lt;TD&gt;World!", "Q", $str);
  11.  
  12.  
  13. $str=preg_replace("!X([0-9].*?)Q!ei", "$zmienna", $str);
  14.  
  15. $str=nl2br($str);
  16.  
  17. return $str;}
  18.  
  19.  
  20. $Code=file_get_contents('http://www.tibia.com/community/?subtopic=character&name=trok'); 
  21. $Code=nl2br(htmlspecialchars($Code)); 
  22. echo htmlspecialchars(bbcode($Code));
  23.  
  24. echo $zmienna;
  25.  
  26. ?>
Go to the top of the page
+Quote Post
bim2
post
Post #16





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


$str=preg_replace("!X([0-9].*?)Q!ei", "$zmienna = \\1", $str);
źle (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
$zmienna=preg_replace("!X([0-9].*?)Q!ei", "\\1", $str);
i w $str masz zmienna (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

A co mi tam:
  1. <?
  2. $sName='trok';
  3. $sCode=file_get_contents('http://www.tibia.com/community/?subtopic=character&name='.$sName); 
  4. $sStr = preg_replace("!(?:.*)<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR=#505050><TD COLSPAN=2 CLASS=white><B>Character Information</B></TD></TR>(.*?)</TABLE>(?:.*)!is", "1", $sCode);
  5. preg_match_all("!<TR(?:.*?)><TD(?:.*?)>(.*?)</TD><TD>(.*?)</TD></TR>!is", $sStr, $aInfo);
  6.  
  7. foreach($aInfo[1] AS $iKey => $sWhat)
  8. {
  9. $sWhat = str_replace(':', '', $sWhat);
  10. $aInfos[$sWhat] = $aInfo[2][$iKey];
  11. }
  12. echo '<pre>';
  13. print_r($aInfos); 
  14. echo '</pre>';
  15. ?>
(IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) I jak?

Ten post edytował bim2 10.10.2006, 20:06:38
Go to the top of the page
+Quote Post
Macok
post
Post #17





Grupa: Zarejestrowani
Postów: 100
Pomógł: 0
Dołączył: 31.08.2006

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


Niewiem jak mam dziekowac (IMG:http://forum.php.pl/style_emoticons/default/snitch.gif)
Powiedz jeszcze tylko jak te array wywalic (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)
Zeby sie wyswietlalo:
Kod
    [Name] => Trok
    [Sex] => male
    [Profession] => Knight
    [Level] => 11
    [World] => Tenebra
    [Residence] => Carlin
    [Last login] => Oct 10 2006, 06:26:28 CEST
    [Account Status] => Free Account

A nie
Kod
Array
(
    [Name] => Trok
    [Sex] => male
    [Profession] => Knight
    [Level] => 11
    [World] => Tenebra
    [Residence] => Carlin
    [Last login] => Oct 10 2006, 06:26:28 CEST
    [Account Status] => Free Account
)


Ten post edytował Macok 10.10.2006, 20:44:41
Go to the top of the page
+Quote Post
bim2
post
Post #18





Grupa: Zarejestrowani
Postów: 1 873
Pomógł: 152
Dołączył: 9.04.2006
Skąd: Berlin

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


foreach" title="Zobacz w manualu php" target="_manual za duzo gotowców (IMG:http://forum.php.pl/style_emoticons/default/biggrin.gif)
Go to the top of the page
+Quote Post

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: 22.08.2025 - 17:21