Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
PHP - Leggere file PHP esterno...dove è presente la stringa.....
Forum - PHP - Leggere file PHP esterno...dove è presente la stringa.....

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
LukeMilan (Normal User)
Rookie


Messaggi: 42
Iscritto: 30/05/2012

Segnala al moderatore
Postato alle 12:35
Martedì, 12/02/2013
Ciao a tutti ragazzi. Ho bisogno di uno script PHP che legga un file esterno (.html) in particolare dove è presente una stringa ( ad esempio <title> ) e quindi ne restituisce la stringa completa( <title>Titolo</title> ).

Grazie mille.:k:

Ultima modifica effettuata da LukeMilan il 12/02/2013 alle 12:36
PM Quote
Avatar
dmr (Normal User)
Pro


Messaggi: 141
Iscritto: 04/01/2012

Segnala al moderatore
Postato alle 15:38
Martedì, 12/02/2013
Si ma qual è il tuo problema? Hai almeno provato a farlo??

PM Quote
Avatar
LukeMilan (Normal User)
Rookie


Messaggi: 42
Iscritto: 30/05/2012

Segnala al moderatore
Postato alle 15:48
Martedì, 12/02/2013
Non ho nessun problema :-|

Ho semplicemente chiesto come fare.

PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 16:50
Martedì, 12/02/2013
Usa file_get_contents per leggere il file, dopodiche' puoi usare una Regex per estrapolare la porzione di testo che ti serve.

http://php.net/manual/en/function.file-get-contents.php

http://www.php.net/manual/en/function.preg-match.php


Il mio blog: https://piero.dev
PM Quote
Avatar
LukeMilan (Normal User)
Rookie


Messaggi: 42
Iscritto: 30/05/2012

Segnala al moderatore
Postato alle 18:48
Martedì, 12/02/2013
Ma posso farlo nelle pagine html di altri siti web? -NO

Quindi la tua soluzione non va bene :(
-------------------------------------------------------
Riscrivo la domanda in modo più semplice:
Dato un url ($url) come faccio a ottenere in output la descrizione($description) e il titolo($title)?
Così va meglio :k:

Ultima modifica effettuata da LukeMilan il 12/02/2013 alle 18:57
PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 19:05
Martedì, 12/02/2013
Testo quotato

Postato originariamente da LukeMilan:

Ma posso farlo nelle pagine html di altri siti web? -NO



E invece si. Non hai nemmeno letto i links che ti ho dato. :pat:


Il mio blog: https://piero.dev
PM Quote
Avatar
LukeMilan (Normal User)
Rookie


Messaggi: 42
Iscritto: 30/05/2012

Segnala al moderatore
Postato alle 19:21
Martedì, 12/02/2013
Ma perché se scrivo:
Codice sorgente - presumibilmente Plain Text

  1. <?php
  2. $homepage = file_get_contents('http://www.google.com/');
  3. echo $homepage;
  4. ?>



Non mi restituisce niente? D:

PM Quote
Avatar
LukeMilan (Normal User)
Rookie


Messaggi: 42
Iscritto: 30/05/2012

Segnala al moderatore
Postato alle 20:07
Martedì, 12/02/2013
Comunque ho provato con questo:
<?php
// Assuming the above tags are at www.example.com
$tags = get_meta_tags('http://www.example.com/');

// Notice how the keys are all lowercase now, and
// how . was replaced by _ in the key.
echo $tags['author'];       // name
echo $tags['keywords'];     // php documentation
echo $tags['description'];  // a php manual
echo $tags['geo_position']; // 49.33;-86.59
?>
Ma non funziona!

PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 23:39
Martedì, 12/02/2013
Controlla la tua configurazione nel php.ini (cosa scritta BENE nella documentazione che ti ho linkato che non hai letto...).

http://www.php.net/manual/en/filesystem.configuration.php# ...

Testo quotato


; Whether to allow the treatment of URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-fopen
allow_url_fopen = On



Il mio blog: https://piero.dev
PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo