카테고리 없음

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

되꼬다음 2020. 11. 9. 15:46
반응형

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://" . $url[host], 443, $errno, $errstr, 3))
	{
		$msg  = "GET " . $url[path] . " HTTP/1.1" . "\r\n";
		$msg .= "Host: " . $url[host] . "\r\n";
		$msg .= "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko" . "\r\n";
		$msg .= 'Connection: close' . "\r\n\r\n";
		if(fwrite($fp, $msg))
		{
			while(!feof($fp)) 
				$res .= fgets($fp, 1024);
		}
		fclose($fp);
	} 
	else
		$res = "ERROR";

	return $res;
}


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

 

2023.01.31 - [분류 전체보기] - php curl로 https 페이지 가져오기

 

php curl로 https 페이지 가져오기

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_HE

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

 

반응형