- github.com/sunra/php-simple-html-dom-parser
- packagist.org/packages/sunra/php-simple-html-dom-parser
- PHP Simple HTML DOM Parser Manual
Installation
"require": { "sunra/php-simple-html-dom-parser": "1.5.2" }
composer require sunra/php-simple-html-dom-parser
Usage
require_once "vendor/autoload.php"; use Sunra\PhpSimple\HtmlDomParser; ... $dom = HtmlDomParser::str_get_html( $str ); or $dom = HtmlDomParser::file_get_html( $file_name ); $elems = $dom->find($elem_name);
require_once "vendor/autoload.php"; use Sunra\PhpSimple\HtmlDomParser; $url = 'http://naver.com'; $context = stream_context_create([ 'http'=>[ 'header'=>'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36' ]]); $html = HtmlDomParser::str_get_html(file_get_contents($url, false, $context)); //$html = HtmlDomParser::file_get_html($url, FALSE, $context, 0); var_dump( $html );
반응형
'lang > php' 카테고리의 다른 글
PHP Codeigniter - idn_to_ascii(): INTL_IDNA_VARIANT_2003 is deprecated (0) | 2018.07.05 |
---|---|
PHP mysql-database-class (0) | 2018.07.04 |
PHP Gouttle DomCrawler Component (0) | 2018.07.02 |
PHP Goutte Cookie (0) | 2018.07.01 |
PHP Guzzle Scraper (0) | 2018.06.30 |