public function getCrawlerInfo() { $data = $this->extractJsonFromPost(); $id = (int) $data['id']; $crawlerModel = new CrawlerModel(); $crawlerInfo = $crawlerModel->getCrawlerInfo($id); $response = array('success' => true, 'data' => $crawlerInfo); $this->jsonResponseOutput($response); }
public function index() { $model = new CrawlerModel(); $this->viewData['sources'] = $model->getAllSources(); echo $this->twig->render('home/index.html.twig', $this->viewData); }
public function index() { $crawlerModel = new CrawlerModel(); $this->viewData['images'] = $crawlerModel->getAllFetchedImages(); echo $this->twig->render('gallery/index.html.twig', $this->viewData); }
public function getImage($returnJson = true) { $url = $_POST['url']; $crawlerId = $_POST['crawler']; $crawlerModel = new CrawlerModel(); $crawlerInfo = $crawlerModel->getCrawlerInfo($crawlerId); if (empty($url)) { return false; } if (empty($crawlerId)) { return false; } $crawlerModel = new CrawlerModel(); $source = $crawlerModel->getSourceById($crawlerInfo['source_type']); $dom = HtmlDomParser::file_get_html($url); $images = $dom->find($source['main_image']); $imgSrc = $images[0]->src; /** * find more sources */ $moreSources = array(); $moreFromBlock = $dom->find('.domainLinkWrapper'); if (isset($moreFromBlock[0])) { $moreSources[] = $moreFromBlock[0]->href; } //paged Collection (suggested boards under pin $pagedCollection = $dom->find('.PagedCollection'); if (isset($pagedCollection[0]) && !empty($pagedCollection[0])) { $boardLinkWrapper = $pagedCollection[0]->find('.boardLinkWrapper'); foreach ($boardLinkWrapper as $blw) { $moreSources[] = $blw->href; } } $imgData = array('image' => $imgSrc, 'more-sources' => $moreSources); if ($returnJson) { echo json_encode($imgData); exit; } else { return $imgData; } }
public function saveSources($sources, $crawlerId, $source_id) { $model = new CrawlerModel(); foreach ($sources as $source) { $model->insertNewTempSource($source, $source_id); } }