PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > i need information from <title> to </title>......
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
i need information from <title> to </title>......

Réponse
 
LinkBack Outils de la discussion
Vieux 13/02/2008, 11h24   #1
mekalai82@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut i need information from <title> to </title>......

hi.. i have to retrive the title tag information? can you tell me. i
am new to the php ........
can you give the example to get the information between <title> to </
title> from the web page...... how shall i get it.
can give the example.....
  Réponse avec citation
Vieux 13/02/2008, 11h38   #2
McKirahan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

<mekalai82@gmail.com> wrote in message
news:ad9b1c49-a962-4b50-9a09-ed8ac2bb9c12@l16g2000hsh.googlegroups.com...
> hi.. i have to retrive the title tag information? can you tell me. i
> am new to the php ........
> can you give the example to get the information between <title> to </
> title> from the web page...... how shall i get it.
> can give the example.....


Get it via:
var s = document.title;
Set it via:
document.title = "whatever";

HTML DOM title Property
http://www.w3schools.com/htmldom/prop_doc_title.asp


  Réponse avec citation
Vieux 13/02/2008, 11h40   #3
james.gauth@googlemail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

On Feb 13, 11:24am, mekala...@gmail.com wrote:
> hi.. i have to retrive the title tag information? can you tell me. i
> am new to the php ........
> can you give the example to get the information between <title> to </
> title> from the web page...... how shall i get it.
> can give the example.....


<?php
$tag = 'title';
$url = 'http://www.example.com';

$html = file_get_contents($url);
if (preg_match_all("/\\<{$tag}\\>(.*?)\\<\\/{$tag}\\>/si", $html,
$matches)) {
print $matches[1][0];
}

?>
  Réponse avec citation
Vieux 13/02/2008, 11h53   #4
McKirahan
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

"McKirahan" <News@McKirahan.com> wrote in message
news:ttSdndz75LOoSy_anZ2dnUVZ_oOnnZ2d@comcast.com. ..
> <mekalai82@gmail.com> wrote in message
> news:ad9b1c49-a962-4b50-9a09-ed8ac2bb9c12@l16g2000hsh.googlegroups.com...
> > hi.. i have to retrive the title tag information? can you tell me. i
> > am new to the php ........
> > can you give the example to get the information between <title> to </
> > title> from the web page...... how shall i get it.
> > can give the example.....

>
> Get it via:
> var s = document.title;
> Set it via:
> document.title = "whatever";
>
> HTML DOM title Property
> http://www.w3schools.com/htmldom/prop_doc_title.asp


My bad; I gave you a JavaScript solution, not PHP.


  Réponse avec citation
Vieux 13/02/2008, 12h08   #5
The Natural Philosopher
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

McKirahan wrote:
> "McKirahan" <News@McKirahan.com> wrote in message
> news:ttSdndz75LOoSy_anZ2dnUVZ_oOnnZ2d@comcast.com. ..
>> <mekalai82@gmail.com> wrote in message
>> news:ad9b1c49-a962-4b50-9a09-ed8ac2bb9c12@l16g2000hsh.googlegroups.com...
>>> hi.. i have to retrive the title tag information? can you tell me. i
>>> am new to the php ........
>>> can you give the example to get the information between <title> to </
>>> title> from the web page...... how shall i get it.
>>> can give the example.....

>> Get it via:
>> var s = document.title;
>> Set it via:
>> document.title = "whatever";
>>
>> HTML DOM title Property
>> http://www.w3schools.com/htmldom/prop_doc_title.asp

>
> My bad; I gave you a JavaScript solution, not PHP.
>
>

Well thats fair enough, because there is no php solution.

Php SETS the title in the first place..;-)
  Réponse avec citation
Vieux 13/02/2008, 12h08   #6
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

On Wed, 13 Feb 2008 12:24:15 +0100, <mekalai82@gmail.com> wrote:

> hi.. i have to retrive the title tag information? can you tell me. i
> am new to the php ........
> can you give the example to get the information between <title> to </
> title> from the web page...... how shall i get it.
> can give the example.....


<?php
//if the line below doesn't work, use curl
$document = file_get_contents('http://example.com/page.html');
$dom = new DOMDocument();
$dom->loadHTML($document);
echo $dom->getElementsByTagName('title')->item(0)->nodeValue;
?>

--
Rik Wasmus
  Réponse avec citation
Vieux 14/02/2008, 01h04   #7
Toby A Inkster
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

McKirahan wrote:
> McKirahan wrote:
>
>> HTML DOM title Property
>> http://www.w3schools.com/htmldom/prop_doc_title.asp

>
> My bad; I gave you a JavaScript solution, not PHP.


No, the HTML DOM will work fine in PHP...

$doc = new DOMDocument;
$doc->loadHTML(file_get_contents('http://www.google.com'));
print $doc->getElementsByTagName('title')->item(0)->textContent;
// prints "Google"

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 15 days, 7:12.]

Mince & Dumplings
http://tobyinkster.co.uk/blog/2008/0...nce-dumplings/
  Réponse avec citation
Vieux 14/02/2008, 05h56   #8
mekalai82@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

On Feb 13, 4:38 pm, "McKirahan" <N...@McKirahan.com> wrote:
> <mekala...@gmail.com> wrote in message
>
> news:ad9b1c49-a962-4b50-9a09-ed8ac2bb9c12@l16g2000hsh.googlegroups.com...
>
> > hi.. i have to retrive the title tag information? can you tell me. i
> > am new to the php ........
> > can you give the example to get the information between <title> to </
> > title> from the web page...... how shall i get it.
> > can give the example.....

>
> Get it via:
> var s = document.title;
> Set it via:
> document.title = "whatever";
>
> HTML DOM title Propertyhttp://www.w3schools.com/htmldom/prop_doc_title.asp


i am getting the title tag information with in the HTML file..

i need to get the information from web page. for example i am having
www.example.com\index.html.
i need to get the title,description from the above URL.
  Réponse avec citation
Vieux 03/03/2008, 12h37   #9
mekalai82@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: i need information from <title> to </title>......

On Feb 13, 4:40 pm, james.ga...@googlemail.com wrote:
> On Feb 13, 11:24 am, mekala...@gmail.com wrote:
>
> > hi.. i have to retrive the title tag information? can you tell me. i
> > am new to the php ........
> > can you give the example to get the information between <title> to </
> > title> from the web page...... how shall i get it.
> > can give the example.....

>
> <?php
> $tag = 'title';
> $url = 'http://www.example.com';
>
> $html = file_get_contents($url);
> if (preg_match_all("/\\<{$tag}\\>(.*?)\\<\\/{$tag}\\>/si", $html,
> $matches)) {
> print $matches[1][0];
>
> }
>
> ?>


Thank you very much for you reply.
i need one more from you....
I am having following line in my URL. i have to get the result from
the the URL
1.http://www.abc/cat=?5
2.http://www.xyz/rat/ani/


URL code :

<strong>Hyperlink:</strong>&nbsp;<a href="http://www.abc/cat=?5"
target="_blank">http://www.abc/cat=?5</a>

<p>&nbsp;</p>
<strong>Hyperlink:</strong>&nbsp;<a href="http://www.xyz/rat/ani/"
target="_blank">http://www.xyz/rat/ani/</a>
<p>&nbsp;</p>
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 00h13.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 1,16154 seconds with 17 queries