- fetching is now done by a global function in fetch.php. This allows to use this functions in test/xpath.php for testing. - besides of user configuration as explained in README.d json files from `mods` are now also loaded and used for fetching articles - loading of json files is done only one time and not for each article to process - test/xpath.php is now a script, which can be used to test a configuration from `mods`-directory Added two mods for 4players and visions.de. TODO: rewrite README.md
38 lines
615 B
PHP
38 lines
615 B
PHP
<?php
|
|
|
|
require_once('../fetch.php');
|
|
|
|
if (count($argv) <= 2) {
|
|
echo 'USAGE: php fetch.php [mod_file] [article_url]' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
$mod = $argv[1];
|
|
$article_url = $argv[2];
|
|
|
|
//
|
|
// Getting json config
|
|
//
|
|
|
|
$json = file_get_contents($mod);
|
|
$data = json_decode($json, true);
|
|
|
|
echo "<pre>";
|
|
print_r($data);
|
|
echo "</pre>";
|
|
|
|
if (json_last_error() != JSON_ERROR_NONE) {
|
|
echo 'Json error' . PHP_EOL;
|
|
exit(1);
|
|
}
|
|
|
|
$config = $data['config'];
|
|
|
|
//
|
|
// Fetching article
|
|
//
|
|
|
|
$owner_uid = 100;
|
|
$article = array( 'link' => $article_url, 'plugin_data' => '' );
|
|
echo fetch_article($article, $config)['content'];
|