コード例 #1
0
ファイル: ImageSaver.php プロジェクト: onlystar1991/mtdb
 /**
  * Downloads and saves multiple images locally.
  * 
  * @param  string $url 
  * @param  string $id
  * @param  string/null $path
  * @param  string/int $num
  * @return void
  */
 public function saveMultiple(array $urls, $id = null, $path)
 {
     if (empty($urls)) {
         return;
     }
     $images = $this->scraper->multiCurl($urls);
     foreach ($images as $k => $v) {
         //we're saving cast images
         if (strpos($k, 'nm') || !$id) {
             try {
                 Imagine::raw($v)->save(public_path($path) . $k . '.jpg', 100);
             } catch (\Exception $e) {
             }
         } else {
             try {
                 $image = Imagine::raw($v);
                 $image->save(public_path($path) . $id . $k . '.jpg', 60);
                 $image->resize(400, null, function ($constraint) {
                     $constraint->aspectRatio();
                 })->save(public_path($path) . $id . $k . '.thumb' . '.jpg', 90);
             } catch (\Exception $e) {
             }
         }
     }
 }
コード例 #2
0
ファイル: DbReview.php プロジェクト: samirios1/niter
 /**
  * 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;
 }
コード例 #3
0
ファイル: ImdbActorData.php プロジェクト: samirios1/niter
 /**
  * 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;
 }
コード例 #4
0
ファイル: ImdbActorData.php プロジェクト: onlystar1991/mtdb
 /**
  * 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;
 }
コード例 #5
0
ファイル: ImdbData.php プロジェクト: onlystar1991/mtdb
 /**
  * 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);
 }