function getLink($goutte, $url) { $crawler = $goutte->request('GET', $url); $status_code = $goutte->getResponse()->getStatus(); $urls = array(); if ($status_code == 200) { // Get total Pages $selector = '//table/tr/td/b[3]'; $totalProds = $crawler->filterXPath($selector)->each(function ($node) { return $node->text(); }); echo $totalProds[0] . 'PHP_EOL'; $productCount = $totalProds[0]; // Get products data $products = getUrlArray($crawler); array_push($urls, $products); $fetched = count($products); // If multiple pages are there $pages = $productCount / $fetched; if ($products % $fetched != 0) { $pages += 1; } if ($pages > 1) { for ($page = 2; $page <= $pages; $page++) { $crawler = $goutte->request('GET', $url . '?page=' . $page); $status_code = $goutte->getResponse()->getStatus(); if ($status_code == 200) { $products = getUrlArray($crawler); array_push($urls, $products); } } } echo count($urls) . PHP_EOL; } return $urls; }
//$iniName = $options['arguments'][0]; $ini = eZINI::instance('site.ini'); $siteUrl = $ini->variable('SiteSettings', 'SiteURL'); $locale = $ini->variable('RegionalSettings', 'Locale'); $outputContent = ''; // fetch objectversion $contentObject = eZContentObjectVersion::fetchVersion($objectVersion, $objectId); $tpl = templateInit(); $tpl->setVariable('contentobject', $contentObject); if (!is_object($contentObject)) { $script->shutdown(); } $contentType = 'text/html'; $newsletterEditionContent = array('html' => '', 'text' => ''); $htmlMailImageInclude = 0; $urlArray = getUrlArray($siteUrl, $currentHostName, $wwwDir); switch ($outputFormatId) { default: // html 0 // html 0 case CjwNewsletterSubscription::OUTPUT_FORMAT_HTML: // textpart $template = 'design:newsletter/skin/' . $skinName . '/outputformat/text.tpl'; $content = $tpl->fetch($template); $content = generateAbsoluteLinks($content, $urlArray); $content = formatText($content); $newsletterEditionContent['text'] = $content; // htmlpart $template = 'design:newsletter/skin/' . $skinName . '/outputformat/html.tpl'; $content = $tpl->fetch($template); $content = generateAbsoluteLinks($content, $urlArray);