파싱, CURL & HTTPS 헤더 확인 > php

본문 바로가기
사이트 내 전체검색

php

파싱, CURL & HTTPS 헤더 확인

페이지 정보

작성자 서방님 댓글 0건 조회 270회 작성일 18-09-19 15:36

본문

<?
/**
 * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
 * array containing the HTTP server response header fields and content.
*/
function get_web_page($url) {
	$options = array(
		CURLOPT_RETURNTRANSFER => true,     // return web page
		CURLOPT_HEADER         => false,    // don"t return headers
		CURLOPT_FOLLOWLOCATION => true,     // follow redirects
		CURLOPT_ENCODING       => "",       // handle all encodings
		CURLOPT_USERAGENT      => "spider", // who am i
		CURLOPT_AUTOREFERER    => true,     // set referer on redirect
		CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
		CURLOPT_TIMEOUT        => 120,      // timeout on response
		CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
		CURLOPT_SSL_VERIFYPEER => false     // Disabled SSL Cert checks
	);

	$ch      = curl_init( $url );
	curl_setopt_array( $ch, $options );
	$content = curl_exec( $ch );
	$err     = curl_errno( $ch );
	$errmsg  = curl_error( $ch );
	$header  = curl_getinfo( $ch );
	curl_close( $ch );

	$header["errno"]   = $err;
	$header["errmsg"]  = $errmsg;
	$header["content"] = $content;
	return $header;
}
?>

댓글목록

등록된 댓글이 없습니다.

Total 612건 7 페이지
게시물 검색

회원로그인

접속자집계

오늘
67
어제
84
최대
1,347
전체
154,438
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.