PHP code example of manofstrong / sitescrapper

1. Go to this page and download the library: Download manofstrong/sitescrapper library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

manofstrong / sitescrapper example snippets



Manofstrong\sitescrapper;
$scrapeThisSite = new SiteScrapper();

$singleSitemapUrl = 'https://www.php.com/sitemap.xml';   // can be .xml or .xml.gz or robots.txt file
$numberOfPages = 2;	// must be a digit without single or double quotation marks: '2' or "2" will fail.
 
$scrapeThisSite -> showContentSiteMap($singleSitemapUrl, $numberOfPages);



Manofstrong\sitescrapper;
$scrapeThisSite = new SiteScrapper();

$singleSitemapUrl = 'https://www.php.com/sitemap.xml';
 
// MySQL table structure in the database folder of this repository
$scrapeThisSite -> databaseCredentials('database','host','username','password'); 

$scrapeThisSite -> singleSiteMap($singleSitemapUrl);


Manofstrong\sitescrapper;
$scrapeThisSite = new SiteScrapper();

$sitemapArray = ['https://site1.com/sitemap.xml','https://site2.com/sitemap.xml','https://site3.com/sitemap.xml'];

// MySQL table structure in the database folder of this repository
$scrapeThisSite -> databaseCredentials('database','host','username','password'); 

$scrapeThisSite -> siteMapsArray($sitemapArray);


Manofstrong\sitescrapper;
$scrapeThisSite = new SiteScrapper();

$sitemapFile  = __DIR__ . '/yourtextfile.txt';
 
// MySQL table structure in the database folder of this repository
$scrapeThisSite -> databaseCredentials('database','host','username','password'); 

$scrapeThisSite -> siteMapFile($sitemapFile);


Manofstrong\sitescrapper;
$scrapeThisSite = new SiteScrapper();

$scrapeThisSite -> setUserAgent('Example User Agent. For Text Data Data Assigment.');