I want to scrape a website content. here is the example html source code of that site.
<div class="entry-content">
<h2>hi tags?</h2>
<ul>
<li>some text</li>
<li>sometext</li>
<li>sometext</li>
<li>sometext</li>
</ul>
<h2>hi tags2 ?</h2>
<ul>
<li>some text</li>
<li>sometext</li>
<li>To ometext</li>
<li>Theometext</li>
</ul> </div>
I want to extract data of <li> tags from first <ul> html code. Here I've tried.
include('../simple_html_dom.php');
// get DOM from URL or file
//$html = check above html code
$articles = $html->find('div[class="entry-content"]') ? $html->find('div[class="entry-content"]') : [];
foreach($articles as $article) {
$items = $article->find('ul',0) ? $article->find('ul',0) : false;
if($items !==false){
$lis = $item->find('li') ? $item->find('li') : [];
foreach($lis as $b){
$mcpcons .= $b->plaintext;
}
}
}
Help me by giving the correct info how can I do that?