Skip to content

proxy 서버 통해서 외부문서 불러오기 curl

조회 수 8152 추천 수 0 2013.02.20 17:35:48

외부문서를 불러올때 fopen, fsoketopen으로 불러오기가 수월치 않을때 curl을 이용해보세요.

해당서버에 curl이 설치되었을경우 이용가능합니다.
설치된경우 php.ini 에서
;extension=php_curl.dll
위와 같이 주석이 되어있다면 제거하세요. ";" 제거
php.ini 저장후 서버 재시동합니다.

# 예제소스
<?
$page_url = "http://www.yahoo.com"; //불러올페이지
$proxy_ip = "111.222.333.444:8080"; //프록시이용시 IP:PORT

function curl_page($page_url,$proxy_ip){
 $ch = curl_init();

 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE);
 curl_setopt($ch, CURLOPT_TIMEOUT, 10);
 curl_setopt($ch, CURLOPT_HEADER, 0);
 curl_setopt($ch, CURLOPT_POST, true);
 curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
 curl_setopt($ch, CURLOPT_URL, $page_url);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
 curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);

 if ($proxy_ip) { //프록시사용시
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
  curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
  curl_setopt($ch, CURLOPT_PROXY, $proxy_ip);
 }

 $result = curl_exec($ch);
 curl_close($ch);

 return $result;
}

//출력
echo curl_page($page_url,$proxy_ip);
?>

profile

일요일은 짜빠게뤼~ 먹는날~^^

엮인글 :
http://adminplay.com/177442/935/trackback
List of Articles
번호 제목 글쓴이 날짜sort 조회 수

CentOS 6.5 에서 VirtualBox 4.3 설치후 VirtualBox 구동...

VirtualBox 4.3 Released – Install on RHEL/CentOS/Fedor...

ctime, mtime, atime 다른 점 설명

ZFS 파일에 ACL 설정

ll 명령시 날짜 전체가 보이도록 하기

ModSecurity 로그파일의 사이즈가 너무 큰데 이를 날짜나 ... file

top 화면 내용중 load average와 PRI : priority(우선순위...

hddtemp와 mrtg를 이용한 하드디스크 온도 체크 file

tar 압축을 실수로 디렉토리 생성 안하고 풀었을때 대처법

windows smartctl

HDD Guardian (a graphical user interface for smartctl)

리눅스 벤치마크 프로그램 목록

Adaptec 컨트롤러 StorMan 에러 및 각종 확인 방법

linux 커널 파라메터 수정

특정 데몬의 메모리 점유율 확인하기

make 정리

What are the bandwidth requirements for running a BigB...

스트리밍 서비스 위한 각 회사 와우자,어도비,마이크로 ...

파일비교 명령어 diff 사용법

웹서버 트래픽 시각화 logstalgia

  • l2zeo
  • 2013-05-03
  • 조회 수 6116

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234