php - Using Laravel Goutte package for scrapping -
but have face problem scrapping targeted site shows me error
"file_get_contents(): ssl operation failed code 1. openssl error messages: error:140770fc :ssl routines:ssl23_get_server_hello:unknown protocol"
my code:
<?php namespace app\http\controllers; use goutte\client; use symfony\component\domcrawler\crawler; use illuminate\http\request; use app\http\requests; use app\library\simple_html_dom; class webscrapercontroller extends controller { public function index() { // create new goutte client instance $client = new client(); // hackery allow https $guzzleclient = new \guzzlehttp\client([ 'timeout' => 60, 'verify' => false, ]); // create dom url or file $html = new \htmldom('https://www.example.com/'); foreach ($html->find('img') $element) { echo $element->src . '<br>'; } // find links foreach ($html->find('a') $element) { echo $element->href . '<br>'; } } }
Comments
Post a Comment