PHP 7 Script to Scrape or Extract Title and Meta Description of Website URL Full Project For Beginners

  • Post author:
  • Post category:PHP
  • Post comments:0 Comments


Welcome folks today in this blog post we will be scraping or extracting the title and meta description of website url in php 7. All the full source code of the application is shown below.




Get Started




In order to get started you need to make an index.php file and copy paste the following code






Extracting Meta Description of Website



$meta_tags = get_meta_tags('');
if (isset($meta_tags['description'])) {
echo $meta_tags['description'];
else {
echo "Meta description not exists";


READ  PHP 7 Script to Sort Associative Array in Browser Full Project For Beginners


Extracting the title of website



  function get_title($url) {
        $fp = file_get_contents($url);
        if (!$fp) 
            return null;
        $res = preg_match("/<title>(.*)<\/title>/siU", $fp, $title_matches);
        if (!$res) 
            return null; 
        $title = preg_replace('/\s+/', ' ', $title_matches[1]);
        $title = trim($title);
        return $title;
echo get_title("");


Leave a Reply