파싱과 프록시 문의드립니다.. 정보
파싱과 프록시 문의드립니다..본문
파싱을 하던 사이트가 있었는데 갑자기 파싱이 안되네요..
소스구조가 달라진 게 아닌걸 보니 아이피 차단을 한것 같습니다..
프록시를 사용하면 될것 같다는 생각이 드는데..
기존 코드에 프록시를 어떻게 적용해야 되는지 모르겠습니다..
------ 기존 코드 中 ------
function get_page($url,$utf8="1",$post="0",$params="")
{
global $ch;
if($post){
curl_setopt($ch, CURLOPT_POST,true);
if($params) curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPGET,false);
}else{
if($params) $url = $url.http_build_query($params);
curl_setopt($ch, CURLOPT_POST,false);
curl_setopt($ch, CURLOPT_HTTPGET,true);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_AUTOREFERER, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiefile');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiefile');
$res = curl_exec($ch);
if($utf8) $res = iconv("euckr","utf8",$res);
return $res;
}
---------------------------
위 부분쯤에 적용을 하면 될것 같은데 방법을 잘 모르겠습니다..
혹시 적용할줄 아시는 분 계신가요??
소스구조가 달라진 게 아닌걸 보니 아이피 차단을 한것 같습니다..
프록시를 사용하면 될것 같다는 생각이 드는데..
기존 코드에 프록시를 어떻게 적용해야 되는지 모르겠습니다..
------ 기존 코드 中 ------
function get_page($url,$utf8="1",$post="0",$params="")
{
global $ch;
if($post){
curl_setopt($ch, CURLOPT_POST,true);
if($params) curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_HTTPGET,false);
}else{
if($params) $url = $url.http_build_query($params);
curl_setopt($ch, CURLOPT_POST,false);
curl_setopt($ch, CURLOPT_HTTPGET,true);
}
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_COOKIESESSION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
curl_setopt($ch, CURLOPT_AUTOREFERER, 120);
curl_setopt($ch, CURLOPT_TIMEOUT, 120);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_3 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8J2 Safari/6533.18.5');
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookiefile');
curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookiefile');
$res = curl_exec($ch);
if($utf8) $res = iconv("euckr","utf8",$res);
return $res;
}
---------------------------
위 부분쯤에 적용을 하면 될것 같은데 방법을 잘 모르겠습니다..
혹시 적용할줄 아시는 분 계신가요??
댓글 전체