curl > 그누보드

본문 바로가기

그누보드

curl

이미지가 없습니다.

<!--?php


function getContent($url) {

    $cookieFile = tempnam(sys_get_temp_dir(), 'cookie'); // 임시 쿠키 파일 생성

    

    $ch = curl_init();


    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36');

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(

        'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',

        'Accept-Language: en-US,en;q=0.5',

        'Connection: keep-alive',

        'Upgrade-Insecure-Requests: 1'

    ));

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookieFile);

    curl_setopt($ch, CURLOPT_COOKIEFILE, $cookieFile);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // SSL 검증 비활성화, 보안상 주의

    curl_setopt($ch, CURLOPT_TIMEOUT, 30);


    $response = curl_exec($ch);


    if (curl_errno($ch)) {

        echo 'cURL error: ' . curl_error($ch);

    } else {

        return $response;

    }


    curl_close($ch);

    unlink($cookieFile); // 쿠키 파일 삭제

}


$url = 'https://www.xxx.co.kr/';

$content = getContent($url);

echo $content;


?-->

관련글
  • PHP proxy 서버 통해서 외부문서 불러오기 curl [출처] PHP proxy 서버 통해서 외부문서 불러오기
  • script
  • upload 설명
  • 확장자 이후 자르기
  • 확장자 뒷부터 자르기
  • strpos
  • PHP 배열 사용법, php배열 다루기
  • mysql 총 갯수
  • 오늘 날짜별로 ~
  • PHP에서 사용할 수 있는 함수 목록
  • 실시간 핫 잇슈
    회사소개 개인정보처리방침 서비스이용약관

    Copyright © www.webstoryboard.com All rights reserved.