티스토리 뷰
반응형
2020년 4월 기준.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://finance.naver.com/sise/sise_rise.nhn');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch);
echo iconv("euc-kr","utf-8", $result);
// https snoopy 안됨. https curl 사용.
preg_match('/<h3 id="articleTitle">(.*?)<\/h3>/is', $result, $text);
echo $text[0];
preg_match('/<div id="articleBodyContents" class="_article_body_contents">(.*?)<\/div>/is', $result, $text);
echo $text[0];
반응형
'Study' 카테고리의 다른 글
Teams(팀즈) auto formatting(자동 포맷) or auto indent(자동 들여쓰기) disable(중단) (0) | 2024.01.21 |
---|---|
Java(자바) API(에이피아이) bearer token 예제 (0) | 2024.01.21 |
Oracle(오라클) Korean(한글) byte(바이트) 관련 (0) | 2024.01.21 |
Sourcetree(소스트리) 관련 (0) | 2024.01.21 |
freemarker(프리마커) 관련 (0) | 2024.01.21 |
댓글