[英]Symfony DomCrawler and OpenSSL Connection Reset errors
我正在學習Symfony爬蟲,想實現如下場景:
我的代碼非常簡單(它運行為 Symfony 命令):
$io = new SymfonyStyle($input, $output);
$url = "https://example.org";
$browser = new HttpBrowser(HttpClient::create());
$crawler = $browser->request('GET', $url);
$form = $crawler->selectButton('submitForm')->form();
$form['field1'] = 'foo'; //temporary data
$form['field2'] = 'bar';
$form['field3'] = 'baz';
$form['field4'] = '12345';
$crawler = $browser->submit($form);
if(!$crawler->getBaseHref() === "https://example.org/error")
{
$nodeValues = $crawler->filter('.section')->each(function (Crawler $node, $i) {
return $node->text();
});
$io->info("Important message: ".$nodeValues[0]);
}
運行它后,95% 的時間我在命令行中收到以下錯誤消息:
在 ErrorChunk.php 第 62 行:OpenSSL SSL_read:連接已重置,“https://example.org”的錯誤號為 10054。
在 CurlResponse.php 行 337:OpenSSL SSL_read:連接已重置,“https://example.org”的錯誤號為 10054。
另一方面,在剩下的 5% 的情況下,我得到了正確的數據。 這是對使用爬蟲的某種保護嗎? 還是我需要設置其他東西?
您可能有舊版本的 OpenSSL。嘗試下載新的 package 或從源代碼編譯。 大多數服務器需要 TLS1.2+,因為它是當前標准。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.