스마트스토어 상세페이지 크롤링 시 503에러
본문
$url = 'https://smartstore.naver.com/zal/products/6355445974';
$headers = array();
$headers['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7';
$headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36';
$headers['Accept-Encoding'] = 'gzip, deflate, br';
$headers['Accept-Language'] = 'ko-KR,ko;q=0.9,en-US;q=0.8,en;q=0.7';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
$response = curl_exec ($ch);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
503에러가 나오는 이유가 무엇일까요? !-->
답변 4
다음 코드 제거
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip');
추가
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
print_r( $status_code); ====>
=====================
Array
(
[url] => https://smartstore.naver.com/zal/products/6355445974
[content_type] => text/html; charset=utf-8
[http_code] => 200
스마트스토어는 크롤링을 막는 봇 차단 정책을 가지고 있을 수 있습니다. 따라서 너무 짧은 시간 간격으로 연속적인 요청을 보내면 서버에서 봇으로 인식하여 차단할 수 있으니 참조하시기 바랍니다.
서버를 재부팅 한번 해보세요
정식 제공하는 api가 아니라서 네이버측에서 막았을 가능성이 가장 높을거 같네요.
curl POST 로 접근해보세요
답변을 작성하시기 전에 로그인 해주세요.