I have been able to use the file_get_contents
to go through a websites news section and grab the title text from each article. How would I then store that information and use it in a section on my website?
my php:
<?php
$html = file_get_contents("https://www.coindesk.com/category/news/");
$dom = new DomDocument();
$internalErrors = libxml_use_internal_errors(true);
$dom->loadHTML($html);
libxml_use_internal_errors($internalErrors);
$finder = new DomXPath($dom);
$classname="fade";
$nodes = $finder->query("//*[contains(@class, '$classname')]");
foreach ($nodes as $node) {
echo $node->nodeValue."<br>";
}
?>
where I want to store it:
<div id="box5" class="toggle" style="display: none;">
<div id="services" class="services">
<div class="container" >
<div class="service-head text-center">
<h2>NEWS</h2>
<span> </span>
</div>
<button class="accordion">STORE THE POST TITLE HERE</button>
<div class="panel1">
<p>STORE THE POST SUMMARY HERE WITH LINKS TO ARTICLE</p>
</div>
<button class="accordion">Section 2</button>
<div class="panel1">
<p></p>
</div>
<button class="accordion">Section 3</button>
<div class="panel1">
<p></p>
</div>
</div>
</div>
</div>