Skip to content

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

조회 수 8153 추천 수 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/a90/trackback
List of Articles
번호 제목 글쓴이 날짜 조회 수sort

[CentOS] ffmpeg 설치

리눅스 - zip 압축 해제

네트워크 관리자를 위한 통합 모니터링 툴 - N.E.W.T file [2]

favicon 만들기

리눅스 - htop file

가볍고 강력한 SNMP를 이용한 모니터링 프로그램입니다. file

CentOS Samba 설정

tar.gz 특정 디렉토리에 압축풀기

오라클11g 설치 (in centOS 5.1)

리눅스 시스템 관리자를 위한 즐겨찾기

netstat 의 Send-Q, Recv-Q의 의미

[FreeBSD]CPU, 메모리, HDD확인 및 네트워크 설정

백 그라운드, 포그라운드 전환

CentOS 5.4 Samba 서버 <-> 윈도우7에서 접근 문제

MS-DOS 배치파일 문법

리눅스 파일 복구 명령 debugfs

리눅스 - tar 압축 사용법

iSCSI 설정하기

리눅스 TIP

CentOS ffmpeg yum install

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234