但我面临着为我的目标网站报废的问题 它显示了一个错误
"file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC
:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol"
我的代码:
<?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 a new Goutte client instance
$client = new Client();
// Hackery to allow HTTPS
$guzzleclient = new \GuzzleHttp\Client([
'timeout' => 60,
'verify' => false,
]);
// Create DOM from URL or file
$html = new \Htmldom('https://www.example.com/');
foreach ($html->find('img') as $element) {
echo $element->src . '<br>';
}
// Find all links
foreach ($html->find('a') as $element) {
echo $element->href . '<br>';
}
}
}