From 6702c3f402c7693dc6cc705af05e71753e51f6ae Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 26 Jun 2023 17:15:28 +0300 Subject: [PATCH] add hostPageDom generate [selectors] attribute --- cli/yggo.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cli/yggo.php b/cli/yggo.php index 5c59709..6dbb58c 100644 --- a/cli/yggo.php +++ b/cli/yggo.php @@ -39,7 +39,17 @@ switch ($argv[1]) { case 'generate': - if (CRAWL_HOST_PAGE_DOM_SELECTORS) { + $selectors = []; + + foreach ((array) explode(';', !empty($argv[3]) ? $argv[3] : (string) CRAWL_HOST_PAGE_DOM_SELECTORS) as $selector) { + + if (!empty($selector)) { + + $selectors[] = trim($selector); + } + } + + if ($selectors) { // Init variables $hostPagesProcessedTotal = 0; @@ -58,7 +68,7 @@ switch ($argv[1]) { $html = str_get_html(base64_decode($hostPageDescription->data)); - foreach ((array) explode(',', CRAWL_HOST_PAGE_DOM_SELECTORS) as $selector) { + foreach ($selectors as $selector) { foreach($html->find($selector) as $element) { @@ -117,8 +127,8 @@ echo '/_/\____/\____/\____(_)' . PHP_EOL; echo PHP_EOL . _('available options:') . PHP_EOL . PHP_EOL; -echo _(' help - this message') . PHP_EOL; -echo _(' hostPageDom generate - make hostPageDom index based on related hostPage.data field') . PHP_EOL; -echo _(' hostPageDom truncate - flush hostPageDom table') . PHP_EOL . PHP_EOL; +echo _(' help - this message') . PHP_EOL; +echo _(' hostPageDom generate [selectors] - make hostPageDom index based on related hostPage.data field') . PHP_EOL; +echo _(' hostPageDom truncate - flush hostPageDom table') . PHP_EOL . PHP_EOL; echo _('get support: https://github.com/YGGverse/YGGo/issues') . PHP_EOL . PHP_EOL;