PHP の cURL について助けが必要です。
ページを取得して JSON に変換しようとしていますが、cURL 応答に奇妙な文字が含まれている
ため、変換できません。この文字は、探しているページの !doctype の直前に表示されます。
header('Content-type: text/html; charset=utf-8');
PHPで設定して使用しました
'Accept: text/xml,application/xml,application/xhtml+xml',
'text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5',
'Accept-Language: fr-fr,fr;q=0.7,en-us;q=0.5,en;q=0.3',
'Accept-Charset: utf-8;q=0.7,*;q=0.7',
'Keep-Alive: 300');
cURL の場合。
cURL コード:
$ch = curl_init($searchUrl);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_setopt($ch, CURLOPT_HEADER, $header);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip,deflate');
curl_setopt($ch, CURLOPT_USERAGENT, $agents[rand(0, count($agents) - 1)]);
$response = curl_exec($ch);
curl_close($ch);
誰にもアイデアがありますか?