PHP code example of piedweb / url-harvester
1. Go to this page and download the library: Download piedweb/url-harvester 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/ */
piedweb / url-harvester example snippets
use \PiedWeb\UrlHarvester\Harvest;
use \PiedWeb\UrlHarvester\Link;
$url = 'https://piedweb.com';
Harvest::fromUrl($url)
->getResponse()->getInfo('total_time') // load time
->getResponse()->getInfo('size_download')
->getResponse()->getStatusCode()
->getResponse()->getContentType()
->getRes...
->getTag('h1') // @return first tag content (could be html)
->getUniqueTag('h1') // @return first tag content in utf8 (could contain html)
->getMeta('description') // @return string from content attribute or NULL
->getCanonical() // @return string|NULL
->isCanonicalCorrect() // @return bool
->getRatioTxtCode() // @return int
->getTextAnalysis() // @return \PiedWeb\TextAnalyzer\Analysis
->getKws() // @return 10 more used words
->getBreadCrumb()
->indexable($userAgent = 'googlebot') // @return int corresponding to a const from Indexable
->getLinks()
->getLinks(Link::LINK_SELF)
->getLinks(Link::LINK_INTERNAL)
->getLinks(Link::LINK_SUB)
->getLinks(Link::LINK_EXTERNAL)
->getLinkedRessources() // Return an array with all attributes containing a href or a src property
->mayFollow() // check headers and meta and return bool
->getDomain()
->getBaseUrl()
->getRobotsTxt() // @return \Spatie\Robots\RobotsTxt or empty string
->setRobotsTxt($content) // @param string or RobotsTxt