카테고리 없음

php curl로 https 페이지 가져오기

되꼬다음 2023. 1. 31. 00:55
반응형
function get_surl($url)
{
	$ch = curl_init();
	
	$header_data = array("User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
			, "Referer: https://am0900.tistory.com");

	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_HEADER, true); // 헤더 정보 보냄
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header_data); 
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_FAILONERROR, true);
 
	$res = curl_exec($ch);
	
	if(!$res) 
	{
		//var_dump(curl_error($ch));
		return "ERROR";
	}
 
    curl_close($ch);

    return $res;
}

echo get_surl("https://am0900.tistory.com");

 

 

2020.11.09 - [분류 전체보기] - php fsockopen으로 https 페이지 가져오기

 

php fsockopen으로 https 페이지 가져오기

fsockopen("ssl://abc.co.kr", 443); host는 ssl:// 로 시작해야 하고, 포트번호는 443으로 설정한다. * https fsockopen 예제 function get_surl($url) { $url = parse_url($url); if($url[path] == "") $url[path] = "/"; if($fp = fsockopen("ssl://"

am0900.tistory.com

2017.08.11 - [분류 전체보기] - curl VS snoopy VS fsockopen VS fopen VS stream 속도비교

 

curl VS snoopy VS fsockopen VS fopen VS stream 속도비교

https://www.hashbangcode.com/article/quickest-way-download-web-page-php Quickest Way To Download A Web Page With PHP | #! code There are lots of different ways to download a web page using PHP, but which is the fastest? In this post I will go through as ma

am0900.tistory.com

 

반응형