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

Bigbluebutton Installation Ubuntu

Installing NGINX, PHP, and MySQL on Ubuntu 10.04 LTS u...

ubuntu 부팅시 서비스 자동실행 및 실행방지

웹 언어별 no-cache 리스트

sysctl 조정 방법

리눅스 메모리 관리, 왜 메모리 여유공간이 없을까? (top ...

[ UDP ] packet buffer size 조절

웹서버 트래픽 시각화 logstalgia

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

파일비교 명령어 diff 사용법

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

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

make 정리

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

linux 커널 파라메터 수정

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

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

HDD Guardian (a graphical user interface for smartctl)

windows smartctl

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

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

Copyright ADMINPLAY corp. All rights reserved.

abcXYZ, 세종대왕,1234

abcXYZ, 세종대왕,1234