«   2018/07   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Archives
Today
31
Total
1,123,200
안정적인 DNS서비스 DNSEver
관리 메뉴

Blue Breeze

PHP simple-html-dom-parser 본문

Language/PHP

PHP simple-html-dom-parser

푸른바람 C/H 2018.07.03 08:30

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 );


'Language > 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 simple-html-dom-parser  (0) 2018.07.03
PHP Gouttle DomCrawler Component  (0) 2018.07.02
PHP Goutte Cookie  (0) 2018.07.01
PHP Guzzle Scraper  (0) 2018.06.30
0 Comments
댓글쓰기 폼