|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
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..... |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
<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 |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
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]; } ?> |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
"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. |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
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..;-) |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
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 |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
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/ |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#9 |
|
Messages: n/a
Hébergeur: |
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> <a href="http://www.abc/cat=?5" target="_blank">http://www.abc/cat=?5</a> <p> </p> <strong>Hyperlink:</strong> <a href="http://www.xyz/rat/ani/" target="_blank">http://www.xyz/rat/ani/</a> <p> </p> |
|
![]() |
| Outils de la discussion | |
|
|