Source code file content

Revision: 60 (of 60)

» Project Revision History

» Checkout URL

subversion / 2c.lt / AddTitle.php

Size: 825 bytes, 1 line
<?php
function getMetaTitle($content){
  $pattern = "|<[\s]*title[\s]*>([^<]+)<[\s]*/[\s]*title[\s]*>|Ui";
  if(preg_match($pattern, $content, $match))
  return $match[1];
  else
  return "";
}
require ("a/conf.php");

	$UrlUzklausa="SELECT id, url from urls order by id desc limit 10";
	$Rez=mysql_query($UrlUzklausa);
	;
	while ($row=mysql_fetch_array($Rez)) {
            $url = $row['url'];             //url to scrape
            $id = $row['id'];
            $content = file_get_contents($url);
             $title = trim(htmlentities(getMetaTitle($content), ENT_QUOTES, 'UTF-8'));
             if (empty($title)){$title=$url;}
            //echo $title." <br>";
            $TitleToUpdate="UPDATE urls
SET title='".$title."'
WHERE id='".$id."' ";
	$UpdateTitle=mysql_query($TitleToUpdate);
        }
mysql_close();
?>
  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close