我正在使用 Goutte 制作网页抓取工具。
为了开发,我保存了一个我想遍历的 .html 文档(所以我不会经常向网站发出请求)。这是我到目前为止所拥有的:
use Goutte\Client;
$client = new Client();
$html=file_get_contents('test.html');
$crawler = $client->request(null,null,[],[],[],$html);
根据我所知道的应该调用 Symfony\Component\BrowserKit 中的请求,并传入原始正文数据。这是我收到的错误消息:
PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\ConnectException' with message 'cURL error 7: Failed to connect to localhost port 80: Connection refused (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in C:\Users\Ally\Sites\scrape\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.
如果我只使用 DomCrawler,那么使用字符串创建爬虫并非易事。(参见:http ://symfony.com/doc/current/components/dom_crawler.html )。我只是不确定如何用 Goutte 做同样的事情。
提前致谢。