링크
http://simplehtmldom.sourceforge.net/ (1206) http://sourceforge.net/projects/simplehtmldom/files/latest/download?source=files (2570)
http://simplehtmldom.sourceforge.net/
다운로드 링크 : http://sourceforge.net/projects/simplehtmldom/files/latest/download?source=files
해당 홈에 나와있는 예제입니다.
간단한 주석을 붙입니다.
//html 을 가져오고
$html = file_get_html('http://www.google.com/');
// 모든 이미지태그를 찾아냅니다.
foreach($html->find('img') as $element)
echo $element->src . '<br>';
// 모든 a태그를 찾아내어 href속성을 뿌려줍니다.
foreach($html->find('a') as $element)
echo $element->href . '<br>';
$html = file_get_html('http://www.google.com/');
// 모든 이미지태그를 찾아냅니다.
foreach($html->find('img') as $element)
echo $element->src . '<br>';
// 모든 a태그를 찾아내어 href속성을 뿌려줍니다.
foreach($html->find('a') as $element)
echo $element->href . '<br>';
// 컨텐츠내에 텍스트들만 가져옵니다.
echo file_get_html('http://www.google.com/')->plaintext;
echo file_get_html('http://www.google.com/')->plaintext;
// css jquery 많이 만져보셨다면 선택자는 거의 동일합니다.
//몇번째 a태그 같은 경우도 가져올수 있구요
foreach($html->find('div.article') as $article) {
$item['title'] = $article->find('div.title', 0)->plaintext;
$item['intro'] = $article->find('div.intro', 0)->plaintext;
$item['details'] = $article->find('div.details', 0)->plaintext;
$articles[] = $item;
}
foreach($html->find('div.article') as $article) {
$item['title'] = $article->find('div.title', 0)->plaintext;
$item['intro'] = $article->find('div.intro', 0)->plaintext;
$item['details'] = $article->find('div.details', 0)->plaintext;
$articles[] = $item;
}
//가져오기전 해당 태그내의 텍스트도 이렇게 간단히 변경가능합니다.
$html->find('div[id=hello]', 0)->innertext = 'foo';
현재 홈에는 예제가 별로 안나와있는데 파일받아보시면
풍부한 예제가 많습니다.
강력추천드립니다 ㅋㅎ
댓글 14개
게시글 목록
| 번호 | 제목 |
|---|---|
| 12357 | |
| 12356 |
MySQL
MySQL php함수 정리 입니다.
|
| 12355 |
MySQL
MySQL php오류 정리 입니다.
|
| 12354 |
MySQL
연산자 관련함수 정리 입니다.
|
| 12353 |
JavaScript
폼 유효성검사해주는 자바스트립트 라이브러리
|
| 20387 | |
| 12352 |
MySQL
수학 관련함수 정리 입니다.
|
| 12351 |
MySQL
문자열 관련함수 정리 입니다.
|
| 12350 |
MySQL
날짜 관련 함수 정리 입니다.
|
| 12349 | |
| 12348 |
jQuery
Ajax 화면 전환 시 애니메이션 효과
|
| 12347 |
MySQL
Query의 기본사용 정리 입니다.
|
| 12346 | |
| 12345 |
MySQL
콘솔 기본명령어 정리 입니다
|
| 12344 |
PHP
암호화 SHA-256
|
| 12343 |
MySQL
mysql 인덱싱 하는 방법 입니다.
|
| 12342 |
MySQL
MySQL 덤프방법(dump) 입니다.
|
| 12341 |
MySQL
여러데이터베이스 사용하는 방법 입니다.
|
| 12340 |
PHP
이미지에 글자쓰기
|
| 12339 |
MySQL
백업&복구(전체/부분/테이블) 하기 입니다.
|
| 12338 |
MySQL
db sql문 정리 입니다.
|
| 12337 | |
| 12336 |
JavaScript
라디오버튼, 체크박스 테두리 없애기 입니다.
|
| 12335 |
JavaScript
현재 페이지 저장하기 입니다.
|
| 12334 |
JavaScript
프린트 출력 자바스크립트 입니다.
|
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기