I need to show some news from web page, so I need to extract data from web site. But I am unable to extract data as the following code:
$html=file_get_html("http://listverse.com/2014/12/01/10-times-us-foreign-policy-was-wildly-inconsistent/");
foreach($html->find('article h2') as $element)
{
echo "<h2>".$element->plaintext."</h2>"."<br>";
foreach ($html->find('article h2 p') as $element1) {
echo "<pre>";print_r($element1->plaintext );
}
But I got correct header but each paragraph is redundant.