Esempio n. 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function handle()
 {
     $this->scraper = new Scraper();
     $this->postRepository = new PostRepository(new Post());
     $this->info("Fetching posts from vdm...");
     $posts = $this->scraper->scrap(200);
     $this->info(sprintf("Saving %d posts.", Arrays::size($posts)));
     Arrays::each($posts, function ($post) {
         $this->postRepository->create($post->toArray());
     });
     $this->info("Done.");
 }
Esempio n. 2
0
 /**
  * Creates corresponding Post model for given DOM object
  *
  * @param  $article : the DOM object
  * @return $post    : Properly formated Post entity
  */
 protected function persistPost($article)
 {
     $post = new Post();
     $post->content = Scraper::parseContent($article);
     $post->date = Scraper::parseDate($article);
     $post->author = Scraper::parseAuthor($article);
     $post->vdm_id = Scraper::parseVdmId($article);
     return $post;
 }
Esempio n. 3
0
 /** @test
  */
 public function itRetrievesGoodAmountOfPosts()
 {
     $scraper = new Scraper();
     $posts = $scraper->setBaseUrl(base_path() . "/tests/test.html")->scrap(10);
     $this->assertEquals(10, Arrays::size($posts));
 }