/** * Scrapes the reviews of provided title from metacritic. * * @param string $title * @return self */ public function get(Title $title) { // $titleName = $title->original_title ? $title->original_title : $title->title; $titleName = $title->title; $url = $this->url($titleName, $title->type); $this->html = $this->scraper->curl($url); $this->title = $title; return $this; }
/** * Downloads and saves single image locally. * * @param string $url * @param string $id * @param string/null $path * @param string/int $num * @return void */ public function saveSingle($url, $id, $path = null, $num = '') { if (!$url) { return; } if (!$path) { $path = 'imdb/posters/'; } $image = $this->scraper->curl($url); //catch error if image we get passed is corrupt and return //false so we wont save a reference of image that doesnt //exist in database. try { Imagine::raw($image)->save(public_path($path) . $id . $num . '.jpg', 100); } catch (\Intervention\Image\Exception\InvalidImageDataStringException $e) { return false; } return true; }
/** * Scrapes given actors page. * * @param string $id * @return self */ private function scrape($id) { $url = 'http://www.imdb.com/name/' . "{$id}/"; $html = $this->scraper->curl($url); $this->crawler = new crawler($html); $this->imdbid = $id; return $this; }
/** * Scrapes given actors page. * * @param string $id * @return self */ private function scrape($id) { $url = 'http://www.imdb.com/name/' . "{$id}/"; $html = $this->scraper->curl($url); $html = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $html); $this->crawler = new crawler($html); $this->imdbid = $id; return $this; }
/** * Fetches now playing movies from imdb. * * @return array */ public function getNowPlaying() { $url = 'http://www.imdb.com/movies-in-theaters/'; $html = $this->scraper->curl($url); $crawler = new Crawler($html); //grab all the movie divs $titles = $crawler->filter('.list.detail')->eq(1)->filter('.list_item'); return $this->compileNowPLaying($titles); }