Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > PHP Forum

PHP Forum Use this forum to discuss all aspects of PHP Development. PHP is a server-side, cross-platform, HTML embedded scripting language that lets you create dynamic web pages.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-12-2008, 03:48 AM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 513
Last Blog:
ubuntu... do not upgra...
Rep Power: 5
phpforfun will become famous soon enough
Default

This one should be easy to explain.

When I type in http:/ /google.com (without the space), here, on code call, it comes out as Google..

whats the code to take the name of the page, not the URL?

after some thought, im gonna take a shot in the dark.

you use the readfile command to read the source of the file
then use preg match to get whatever is between the <title></title> tags
then echo it?

Tried these
PHP Code:
<?
$viewsource
="http://google.com";

        
$lines file("$viewsource");

        foreach (
$lines as $line_num => $line) {
         if (
stristr($lines,"<title>")){
            
$title2=strip_tags($lines);
            Echo 
$title2;
         }

        }



?>
PHP Code:
<?
      $file
=fopen("http://google.com",r);
    
$read fgets($file,255); 
         if (
stristr($file,"<title>")){
            
$title=strip_tags($read);
         }
      
fclose($file);

Echo 
$title;
?>
No luck, am I close?

Last edited by John; 05-12-2008 at 12:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-12-2008, 09:23 AM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Age: 25
Posts: 4,512
Last Blog:
Zend: PHP Security Web...
Rep Power: 50
Jordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud ofJordan has much to be proud of
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default Re: How to take the true name of the site from the URL

You have the concept correct, just need to work on your code a bit.
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-12-2008, 12:30 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 513
Last Blog:
ubuntu... do not upgra...
Rep Power: 5
phpforfun will become famous soon enough
Default Re: How to take the true name of the site from the URL

which one do you like more? first one or second one, lol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-12-2008, 12:52 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,345
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: How to take the true name of the site from the URL

PHP Code:
<?php
$content 
file_get_contents("http://www.google.com");
preg_match('#<title>(.*?)</title>#'$content$title);
$title[1];
?>
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-12-2008, 02:42 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 2,969
Last Blog:
Piano Exam
Rep Power: 25
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: How to take the true name of the site from the URL

What does the function preg_match() do? Does this mean you have to download the entire webpage before you can extract the title?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 05-12-2008, 05:32 PM
phpforfun's Avatar   
phpforfun phpforfun is offline
Programming God
 
Join Date: Feb 2008
Posts: 513
Last Blog:
ubuntu... do not upgra...
Rep Power: 5
phpforfun will become famous soon enough
Default Re: How to take the true name of the site from the URL

Quote:
Originally Posted by John View Post
PHP Code:
<?php
$content 
file_get_contents("http://www.google.com");
preg_match('#<title>(.*?)</title>#'$content$title);
$title[1];
?>
Wow! Thanks john.

working on my new proxy.
test

The first AnalyzeThatHost sets Analyze That Host as a variable, then searches for the title, and searches for the shortcut icon, and if it has one, it uses it as the image..

not too bad?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 05-12-2008, 07:17 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,345
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: How to take the true name of the site from the URL

Quote:
Originally Posted by Xav View Post
What does the function preg_match() do? Does this mean you have to download the entire webpage before you can extract the title?
preg_match is a function to parse content using a regular expression. It can be used to parse websites (html) or plain text documents.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 05-13-2008, 02:21 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 2,969
Last Blog:
Piano Exam
Rep Power: 25
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: How to take the true name of the site from the URL

So you need to download the entire page first, then parse out the <title> tags? Does this slow things down?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 05-13-2008, 03:24 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 19
Posts: 2,345
Last Blog:
PHP Function Overloadi...
Rep Power: 50
John is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of lightJohn is a glorious beacon of light
Send a message via AIM to John
Default Re: How to take the true name of the site from the URL

Quote:
Originally Posted by Xav View Post
So you need to download the entire page first, then parse out the <title> tags? Does this slow things down?
There's no faster way to do it.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Blog
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 05-13-2008, 03:25 PM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 2,969
Last Blog:
Piano Exam
Rep Power: 25
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: How to take the true name of the site from the URL

Can't you just, like, read a certain amount, until you reach the <title> tags?
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Java:Tutorial - Tic-Tac-Toe John Java Tutorials 25 02-27-2008 06:41 PM
Top 10 Ways To Promote Your Web Site ravs2k6 Marketing 30 02-02-2008 04:20 AM
Operators clookid PHP Tutorials 1 01-11-2007 08:35 PM
Online RPG For Sale - Predicted PR 5 phb50530 Site Reviews 10 01-10-2007 05:59 AM


All times are GMT -5. The time now is 05:45 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads