PHP code example of gdianov / araneus

1. Go to this page and download the library: Download gdianov/araneus 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/ */

    

gdianov / araneus example snippets




ate new Rule
class TitleRule extends \Araneus\Rules\BaseRule implements  \Araneus\Interfaces\RuleInterface
{
    public function getPattern(): string
    {
        return '|<title[^>]*

$parseHttp = new \Araneus\Parser(
  new \Araneus\Http\Http('https://google.com')
);

//Attach created rule
$parseHttp->attachRules(new TitleRule()); //You can attach many rules

$result = $parser->run()->fetch(); //array key = regexp, value = found values     
$result = $parser->run()->fetchRules(); //array of Rule objects

              ...

$parseTxt = new \Araneus\Parser(
    new \Araneus\File\FilePlainText(__DIR__.'/dst/txt/demo.txt')
);

$parseTxt->attachRules(
  new NumberRule(), 
  new DirtyWordsRule(),
  new UidRule()
);

$result = $parseTxt->run()->fetch();

$parseDocx = new \Araneus\Parser(
    new \Araneus\File\FileDocument(__DIR__.'/dst/documents/demo.docx')
);

$parseDocx->attachRules(
  new UsersRule(),
  new LinksToBooksRule()
);

$result = $parseDocx->run()->fetch();