Essence\Essence::crawl PHP Method

crawl() public method

Crawls the given source for extractable URLs, optionnaly resolving them relatively to a base one.
See also: Essence\Crawler::crawl()
See also: Essence\Utility\Url::resolve()
public crawl ( string $source, string $base = '' ) : array
$source string HTML source.
$base string Base URL.
return array URLs.
    public function crawl($source, $base = '')
    {
        $urls = $this->_Crawler->crawl($source);
        return $base ? Url::resolveAll($urls, $base) : $urls;
    }

Usage Example

 /**
  *
  */
 public function testCrawl()
 {
     $source = 'source';
     $urls = [];
     $Crawler = $this->getMockBuilder('\\Essence\\Crawler')->disableOriginalConstructor()->getMock();
     $Crawler->expects($this->once())->method('crawl')->with($this->isEqual($source))->will($this->returnValue($urls));
     $Essence = new Essence(['Crawler' => $Crawler]);
     $this->assertEquals($urls, $Essence->crawl($source));
 }