I need to gather all this data from a specific site. I need the URL, Image, Text. Here is the code I am trying to use. But I need to gather all the pieces of info from all the tags on the page.
<article>
<a href="http://www.link.com">
<div><img src="https://image.com/image.png" /></div>
<div>History</div>
<div><h3>Content Here.</h3></div>
</article>
<article>
<a href="http://www.link.com">
<div><img src="https://image.com/image.png" /></div>
<div>History</div>
<div><h3>Content Here.</h3></div>
</article>
<article>
<a href="http://www.link.com">
<div><img src="https://image.com/image.png" /></div>
<div>History</div>
<div><h3>Content Here.</h3></div>
</article>
php code
$html = file_get_contents($feed_url);
$dom = new DOMDocument();
@$dom->loadHTML($html);
$xpath = new DomXPath($dom);
$articles = $xpath->query("//article");
$items = array();
foreach($articles as $article) {
$link = $xpath->query("//a/@href", $article);
$img = $xpath->query("//img/@src", $article);
$link = $xpath->query("//h3", $article);
}
I can't seem to get this to return any values. I can get a single value through the foreach. But I need all the others as well. I can't quite figure out how to make this happen. Any help would be highly appreciated.