PHP Classes

PHP Crawl Sitemap Generator: Crawl Web site and generate a XML sitemap

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 507 All time: 5,783 This week: 43Up
Version License PHP version Categories
crawl-sitemap 1.0.0GNU General Publi...5XML, PHP 5, Searching, SEO
Description 

Author

This class can crawl Web site and generate a XML sitemap.

It crawls a given site retrieving the Web pages, parsing the HTML to extract the links to other pages.

The class parses the linked pages recursively until all links have been followed.

It can exclude a given list of directories so any contained URLs will not be crawled.

It generates a XML sitemap from the list of crawled pages and stores it in the sitemap.xml file.

Picture of Gianluca Zanferrari
  Performance   Level  
Name: Gianluca Zanferrari <contact>
Classes: 19 packages by
Country: The Netherlands The Netherlands
Age: 58
All time rank: 1674 in The Netherlands The Netherlands
Week rank: 49 Up1 in The Netherlands The Netherlands Up
Innovation award
Innovation award
Nominee: 5x

Example

<?php
require_once('sitemap.class.php');
set_time_limit(0);

// replace the example URL with a real one
$targetUrl = 'http://www.yoursite.com/';
$arrExcludeFolders = array('http://www.yoursite.com/images/'); // empty array for no folder excluding

$sm = new sitemap($targetUrl, $arrExcludeFolders);

$sm->crawl($targetUrl);

// see class for more options
$sm->set_change_frequency('daily');

// leave second parameter for no output to browser
$sm->write_xml('sitemap.xml', TRUE);


  Files folder image Files (3)  
File Role Description
Plain text file simple_html_dom.php Class html dom class
Plain text file sitemap.class.php Class class itself
Accessible without login Plain text file sitemap.example.php Example example script

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:507
This week:0
All time:5,783
This week:43Up