donfanning
8/15/2018 - 12:49 PM

webscrapping example

webscrapping example

<?php

// mkdir webscrapping folder
// cd webscrapping
// Then run composer require fabpot/goutte
// then create index.php with below content

require __DIR__ . '/vendor/autoload.php';



use Goutte\Client;

$client = new Client();
$uri = 'http://www.goal.com/es/partido/deportivo-la-coru%C3%B1a-v-sevilla/comentario-resultados/b07sxrrw4roi1qsjvhdumagyy';
$crawler = $client->request('GET', $uri);
$comment = $crawler->filter("[class='widget-match-commentary clearfix']");
$commentTitle = $comment->filter("[class='card-title']");
//print $commentTitle->text();
$commentDescription = $comment->filter("[class='comment-desc']")->text();
//print_r($commentDescription);


$client = new Client();
$uri = 'https://hdfull.tv/';
$crawler = $client->request('GET', $uri);
$contentVideos = $crawler->filter("[class='breakaway-wrapper-dark']");
$videos = [];
$contentVideosHtml = $contentVideos->filter("[class='flickr item left home-thumb-item']")->each(function ($nodeVideo) {
  print $nodeVideo->html();
});
//print $contentVideosHtml->html();
//print_r($contentVideosHtml);

print $contentVideos->filter("[class='section-title']")->children()->first()->html();