library skraypar
Scraper with pattern parsing
irfan-dahir/skraypar
Scraper with pattern parsing
- Sunday, June 24, 2018
- by irfan-dahir
- Repository
- 2 Watchers
- 2 Stars
- 36 Installations
- PHP
- 0 Dependents
- 0 Suggesters
- 0 Forks
- 0 Open issues
- 1 Versions
- 1700 % Grown
Skraypar - Pattern Parser
Developing as a core parsing feature of (but not limited to) the Jikan API as a separate abstraction class., (*1)
Work in Progress, (*2)
Installation
- This library uses Composer, install that first.
composer require irfan-dahir/skraypar
Usage
<?php
require 'vendor/autoload.php';
class Parser extends \Skraypar\Skraypar {
public function loadRules() { // Abstract function
$this->addRule(
'anime_url', // used as a hash key
'~<meta property="og:url" content="(.*?)">~', // Pattern to match
function() { // Function to execute when matched
/*
* $this->matches // output of pattern match
* $this->line // current line
* $this->lineNo // current line no.
* $this->file // All lines in an array
*/
var_dump($this->matches);
}
);
// Add more Rules here
}
}
$parser = new Parser;
$parser->setPath('http://myanimelist.net/anime/1');
$parser->loadFile();
$parser->loadRules();
$parser->parse();
Outputs, (*3)
array (size=2)
0 => string '<meta property="og:url" content="https://myanimelist.net/anime/1/Cowboy_Bebop">' (length=79)
1 => string 'https://myanimelist.net/anime/1/Cowboy_Bebop' (length=44)
MORE EXAMPLES, (*4)
Dependencies
If you found this useful, please feel free to donate!, (*5)
, (*6)
dev-master
9999999-dev
Scraper with pattern parsing
Sources
Download
GPL-3.0
The Requires
by
irfan-dahir