문제

특정 DIV에서 일부 콘텐츠를 구문 분석하고 외부 파일에 저장하려고합니다.이 작동하지만 다음을 수행 할 수 없었습니다

class class league_container

  1. class bar 클래스와 함께 모든 div를 제거합니다
  2. 모든 링크를 스트립하십시오.(텍스트를 남기지 만 PROMATIONACODETAGCODE와 속성을 제거하십시오)
  3. 지금까지 가지고있는 것 :

       <?php
        include( 'simple_html_dom.php'); 
        $html = file_get_html('https://some.domain.com/');
    
        $divContents = array();
    
        foreach ($html->find('div.league_container') as $div) 
        {
            $divContents[] = $div->outertext;
        }       
    
    
    file_put_contents('parser/est-results.htm', implode(PHP_EOL, $divContents));
    ?>
    
    .

    도움이되는 모든 도움이 될 것입니다.

도움이 되었습니까?

해결책

outertext = 사용 :

$div->outertext = '';
$a->outertext = $a->text();
.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top