スクレイピングでエラー発生:cURL error 1: Received HTTP/0.9 when not allowed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
目次
スクレイピングでエラー発生:cURL error 1: Received HTTP/0.9 when not allowed (see https://curl.haxx.se/libcurl/c/libcurl-errors.html)
商品レビューのスクレイピング中にエラーが発生。
どうやら其々のアプリの依存性によるエラーの様子。
Goutteの実行中にcURLが閉じられていない事が原因
参考サイトを読み取ると、エラーの原因がなんとなくわかってきました。
cURLを旧バージョンにするとエラーが起きないとか、2つのアプリの関係性に原因がある様です。
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php書換えで回避可能
旧バージョンを再インストールなんて事は出来れば回避したいモノ。
その辺も参考サイトに記載がありました。
CurlFactory.phpを書き換えればOK
私も無事この方法で解決しました。
参考スクリプト
vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php 65行目~78行目辺り
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
public function release(EasyHandle $easy) { $resource = $easy->handle; unset($easy->handle); if (count($this->handles) >= $this->maxHandles) { curl_close($resource); } else { // Remove all callback functions as they can hold onto references // and are not cleaned up by curl_reset. Using curl_setopt_array // does not work for some reason, so removing each one // individually. curl_setopt($resource, CURLOPT_HEADERFUNCTION, null); curl_setopt($resource, CURLOPT_READFUNCTION, null); curl_setopt($resource, CURLOPT_WRITEFUNCTION, null); curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null); curl_reset($resource); $this->handles[] = $resource; } } |
これを下のようにします。
1 2 3 4 5 6 7 |
public function release(EasyHandle $easy) { $resource = $easy->handle; unset($easy->handle); curl_close($resource); } |
※ /* */で殺してもいいのですが、判り易く消去してみました。
まとめ
翻訳機が無かったら修正できなかったのは間違いない。
英語勉強しましょう。
-
前の記事
楽天市場の商品レビュー取得について問い合わせた内容と解答 2020.06.04
-
次の記事
楽天スーパーセールでランキング取得APIに起きた不具合 2020.06.08
コメントを残す