"PHP Simple HTML DOM Parser"의 두 판 사이의 차이

잔글 (봇: 자동으로 텍스트 교체 (-source +syntaxhighlight))
 
(사용자 2명의 중간 판 22개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개념==
==개념==
;PHP SImple HTML DOM Parser
;PHP Simple HTML DOM Parser, SimpleHTMLDom, simplehtmldom
;PHP 심플 HTML DOM 파서
* "PHP용 빠르고, 간단하고, 신뢰할 수 있는 HTML 문서 파서"
* HTML DOM 처리기
* HTML DOM 처리기
* PHP 5+ 이상에서 사용 가능
* MIT 라이선스
* jQuery와 같이 HTML에서 tag를 찾을 수 있음
 
==설치==
<syntaxhighlight lang='bash'>
composer require simplehtmldom/simplehtmldom
</syntaxhighlight>
 
==예시1: 문자열 입력==
<syntaxhighlight lang='php' run>
use simplehtmldom\HtmlDocument;
 
$html = new HtmlDocument();
$html->load('<div id="hello">Hello</div><div id="world">World</div>');
$html->find('div', 1)->class = 'bar';
$html->find('div[id=hello]', 0)->innertext = 'foo';
echo $html; # <div id="hello">foo</div><div id="world" class="bar">World</div>
</syntaxhighlight>
 
==예시2: URL 입력==
<syntaxhighlight lang='php' run>
use simplehtmldom\HtmlDocument;
 
$html = new HtmlDocument();
$html->load_file('https://ko.wikipedia.org/');
echo $html->find('title', 0)->plaintext; # 위키백과, 우리 모두의 백과사전
</syntaxhighlight>


==참고==
==참고==
* http://simplehtmldom.syntaxhighlightforge.net/
* https://simplehtmldom.sourceforge.io/
* https://github.com/simplehtmldom/simplehtmldom
* https://packagist.org/packages/simplehtmldom/simplehtmldom


[[분류: PHP]]
[[분류: simplehtmldom]]
[[분류: DOM]]
[[분류: HTML 파서]]
[[분류: 파서]]
[[분류: PHP 패키지]]

2021년 9월 12일 (일) 15:10 기준 최신판

1 개념[ | ]

PHP Simple HTML DOM Parser, SimpleHTMLDom, simplehtmldom
PHP 심플 HTML DOM 파서
  • "PHP용 빠르고, 간단하고, 신뢰할 수 있는 HTML 문서 파서"
  • HTML DOM 처리기
  • MIT 라이선스

2 설치[ | ]

Bash
Copy
composer require simplehtmldom/simplehtmldom

3 예시1: 문자열 입력[ | ]

PHP
Copy
use simplehtmldom\HtmlDocument;

$html = new HtmlDocument();
$html->load('<div id="hello">Hello</div><div id="world">World</div>');
$html->find('div', 1)->class = 'bar';
$html->find('div[id=hello]', 0)->innertext = 'foo';
echo $html; # <div id="hello">foo</div><div id="world" class="bar">World</div>
Loading

4 예시2: URL 입력[ | ]

PHP
Copy
use simplehtmldom\HtmlDocument;

$html = new HtmlDocument();
$html->load_file('https://ko.wikipedia.org/');
echo $html->find('title', 0)->plaintext; # 위키백과, 우리 모두의 백과사전
Loading

5 참고[ | ]