PHP script to find Apple Touch Icon

I have a PHP script that crawls a page and extracts the first image in the page, this isn't working too well, and I'd rather get no results than a completely ambiguous picture, so is it possible to modify the following script to extract the universal URL of the first link rel="apple-touch-icon" or link rel="apple-touch-icon-precomposed"?

<?php
if($_REQUEST['url']!='')
{
function get($a,$b,$c)
{ // Gets a string between 2 strings
$y = explode($b,$a);
$x = explode($c,$y[1]);
return $x[0];
}
$url=get_meta_tags("".$_REQUEST['url'].""); 
?>

<div class="addSitetitle"><?php echo get(file_get_contents(''.$_REQUEST['url'].''), "<title>", "</title"); ?></div>
<div class="addSitedescription"><?php echo ($url["description"]); ?></div>
<div class="addSitekeywords"><?php echo ($url["keywords"]); ?></div>
<div class="addSitecopyright"><?php echo ($url["copyright"]); ?></div>
<div class="addSiteimage"><img <?php echo get(file_get_contents(''.$_REQUEST['url'].''), "<img", "/>"); ?> /></div>

Edited to include get function.

Answers


using this, you can obtain links to the images with code such as:

$html = file_get_html($url);
$img = $html->find('img[rel=apple-touch-icon]');
echo $img->href;

Need Your Help

Installing Software in Linux Ubuntu - shotdetect for detecting video shots

compiler-errors ffmpeg make ubuntu-10.04

I have got many errors while installing shotdetect software. some errors were because of the dependencies and that is resolved.Its able to configure perfect but "make" i.e., running make file is th...

How do I get my create action to work for both a nested & non-nested resource?

ruby-on-rails ruby-on-rails-3 has-and-belongs-to-many nested-resources

So I have two models Topic, Client. A Client has_and_belongs_to_many :topics, and a Topic has_and_belongs_to_many :clients.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.