채택완료

크롤링에서요 outertext 함수를 쓰려면 어떻게 해야할까요??

$dom = new simple_html_dom;
$dom -> load($contents);


//html_no_comment();
//outertext($dom );
$dom2 -> outertext($dom );

 

클래스를 잘안써봐서그런지 느낌이 확안오네요 흑흑

 

$dom2 -> outertext($dom );

 

dom2 에 outertext 함수 값을 넣고 출력해주려면 어떻게 해야할까요??

 

|

답변 1개

채택된 답변
+20 포인트

outertext사용방법의 예를 안내드리겠습니다.

Copy
// 요소에서 태그를 제외한 텍스트 검색
echo $html->plaintext;

 

// 요소 외부에 다른 요소를 설정합니다.
$e->outertext = '<div class="wrap">'.$e->outertext.'<div>';

 

// 빈 문자를 설정하고 요소를 삭제합니다.
$e->outertext = '';

 

// 요소 뒤에 추가
$e->outertext = $e->outertext.'<div>foo<div>';

 

// 요소 앞에 삽입
$e->outertext = '<div>foo<div>'.$e->outertext;
출처: https://pikabu.tistory.com/124 [피카부:티스토리]

답변을 작성하려면 로그인이 필요합니다.