Forum Moderators: coopster

Message Too Old, No Replies

How to retrieve Title value from particular URL with PHP?

         

toplisek

8:38 pm on Jan 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



How to retrieve Title value from particular URL with PHP and also organised source code (not float over all screen)?

mack

1:24 pm on Jan 25, 2009 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



There are a few ways to do this. Curl is probably the easiers, although fopen may work on some systems bepending on how the sysstem has been configured.

What you may wish to do is use curl to retreive the paege then store it as a dom object.

Mack.

toplisek

8:02 pm on Jan 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Ho wot do this:
curl to retreive the paege then store it as a dom object.

whoisgregg

6:23 am on Jan 28, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd start by taking a look at the cURL php manual page [php.net] then, if your host supports it, the DOM functions [php.net].

Although, frankly, if all you want is the title, then once you've grabbed the page with cURL I'd just grab the <title> tag with some regex:

// we assume that $page is the html of the page you grabbed with cURL
preg_match('/<title>([^<]+)</title>/', $page, $matches);
print_r($matches);