simple_html_dom 사이트에서 simple_html_dom.php 다운로드를 합니다.
다운로드 URL : https://sourceforge.net/projects/simplehtmldom/files/simplehtmldom/ 에서 최신버전 다운로드
온라인 설명서 URL : http://simplehtmldom.sourceforge.net/manual.htm 개발시 참조
<?php
header('Content-Type: text/html; charset=UTF-8');
//simple_html_dom php 파일을 include함
include('simple_html_dom.php');
//가져올 url 설정
$url = 'https://tv.zum.com/ranking';
$html = @file_get_html($url);
unset($arr_result);
$arr_result = $html->find('div.tv_wrap>a'); //1위 ~ 3위 랭킹순위 및 프로그램명 가져오기
if(count($arr_result) > 0){ //위의 이미지에서 a 태그에 포함되는 html dom 객체를 가져옴
foreach($arr_result as $e){
//children 속성을 이용해 맨 처음(0)의 태그 가져오기(<span class="rank_num">1</span>값 가져옴)
echo $e->children(0)->plaintext.':'; //위의 값 중 1 값을 가져옴
//children 속성을 이용해 맨 두번째(1)의 태그(<div class="tv_info">) 안의 두번째(1)의 태그 가져오기(<p class="program">미스트롯</p>값 가져옴)
echo $e->children(1)->children(1)->plaintext.'<br/>'; //위의 값 중 미스트롯 값을 가져옴
}
} else {
echo "<br/>";
}
unset($arr_result);
$arr_result = $html->find('div.list_wrap>div.list'); //4위 ~ 50위 랭킹순위 및 프로그램명 가져오기
if(count($arr_result) > 0){
foreach($arr_result as $e){
echo $e->children(1)->plaintext.':';
echo $e->children(2)->children(1)->children(0)->plaintext.'<br/>';
}
} else {
echo "<br/>";
}
exit;
?>
https://sourceforge.net/projects/simplehtmldom/postdownload
Find out more about PHP Simple HTML DOM Parser | SourceForge.net
Why SourceForge? We have the most robust search and discovery system of any open source repository on the web, and offer an unparalleled experience for end-users looking for software binaries they can download and install with the click of a button. We're
sourceforge.net
==========================================
https://infotake.tistory.com/98
PHP 외부 사이트 가져 오기, 크롤링 - Snoopy.class
촌놈입니다... 고객분이 GitHub의 MarkDown 페이지를 긁어 오기를 요청 하였는데요... 모듈을 알아보던중 Snoopy.class.php 를 테스트 해보게 되었습니다. 실습환경 - PHP 5.6.9 - 가비아 호스팅 - Snoopy...
infotake.tistory.com
https://sourceforge.net/projects/snoopy/
Snoopy
Download Snoopy for free. Snoopy is a PHP class that simulates a web browser. It automates the task of retrieving web page content and posting forms, for example.
sourceforge.net
'[ Web 관련 ] > php' 카테고리의 다른 글
★ php 정규식 ★ (0) | 2021.07.28 |
---|---|
php 배열의 정렬 - 1차원 배열, 다차원 배열 (0) | 2021.07.26 |
php ajax 샘플 (0) | 2021.05.28 |
php 파일 업로드 설정, php.ini 옵션 (0) | 2021.05.10 |
php 다른 확장자도 php 처럼 실행 되도록 하기 (확장자변경) (0) | 2021.04.24 |