php curl 에서 자주 사용 하 는 5 가지 전형 적 인 예
1,무 접근 제어 파일 캡 처
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://localhost/mytest/phpinfo.php");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // ,
$result=curl_exec($ch);
curl_close($ch);
?>
2,대리 로 캡 처왜 대리 로 캡 처 를 해 야 합 니까?구 글 의 경우 구 글 의 데 이 터 를 잡 으 러 가면 짧 은 시간 안에 자주 잡 으 면 잡 을 수 없습니다.구 글 이 ip 주 소 를 제한 할 때 대 리 를 바 꿔 서 다시 잡 을 수 있 습 니 다.
<pre name="code" class="php"><?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://blog.51yip.com");
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE);
curl_setopt($ch, CURLOPT_PROXY, 125.21.23.6:8080);
//url_setopt($ch, CURLOPT_PROXYUSERPWD, 'user:password'); ,
$result=curl_exec($ch);
curl_close($ch);
?>
3,post 데이터 후,데이터 캡 처데이터 제출 데 이 터 를 따로 말씀 드 리 겠 습 니 다.curl 을 사용 할 때 데이터 교환 이 있 을 때 가 많 기 때문에 중요 합 니 다.
<?php
$ch = curl_init();
/* ,
* array('name'=>serialize(array('tank','zhang')),'sex'=>1,'birth'=>'20101010')
* array('name'=>array('tank','zhang'),'sex'=>1,'birth'=>'20101010') */
$data = array('name' => 'test', 'sex'=>1,'birth'=>'20101010');
curl_setopt($ch, CURLOPT_URL, 'http://localhost/mytest/curl/upload.php');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_exec($ch);
?>
upload.php 파일 에서 printr($_POST);curl 을 이용 하면 upload.php 출력 내용 을 추출 할 수 있 습 니 다.Array([name]=>test[sex]=>1[birth]=>20101010)4.페이지 접근 제어 가 있 는 페이지 를 캡 처 합 니 다.
이전에 한 편 을 쓴 적 이 있 는데,페이지 접근 제어 의 세 가지 방법 에 관심 이 있 으 면 한번 볼 수 있다.
위 에서 언급 한 방법 으로 잡 으 면 다음 과 같은 실 수 를 할 것 이다.
You are not authorized to view this page
You do not have permission to view this directory or page using the credentials that you supplied because your Web browser is sending a WWW-Authenticate header field that the Web server is not configured to accept.
이 럴 때 우 리 는 CURLOPTUSERPWD 가 검증 을 하 러 왔 습 니 다.
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://club-china");
/*CURLOPT_USERPWD
* htpasswd 。*/
//curl_setopt($ch, CURLOPT_USERPWD, 'user:password');
curl_setopt($ch, CURLOPT_HTTPGET, 1);
curl_setopt($ch, CURLOPT_REFERER, "http://club-china");
curl_setopt($ch, CURLOPT_HEADER, 0);
$result=curl_exec($ch);
curl_close($ch);
?>
이상 의 php curl 에서 자주 사용 하 는 5 가지 전형 적 인 예 는 바로 편집장 이 여러분 에 게 공유 한 모든 내용 입 니 다.여러분 께 참고 가 되 고 저희 도 많이 사랑 해 주 셨 으 면 좋 겠 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Laravel - 변환된 유효성 검사 규칙으로 API 요청 제공동적 콘텐츠를 위해 API를 통해 Laravel CMS에 연결하는 모바일 앱(또는 웹사이트) 구축을 고려하십시오. 이제 앱은 CMS에서 번역된 콘텐츠를 받을 것으로 예상되는 다국어 앱이 될 수 있습니다. 일반적으로 ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.