// Get the page's HTML
$html = file_get_contents("http://www.wolverinegreen.com/sports/m-wrestl/spec-rel/utva-m-wrestl-spec-rel.html");
// Create a DOMDocument object and load the html into it
$dom = new DOMDocument();
$dom->loadHTML($html);
// Create an XPath object using the DOMDocument
$xpath = new DOMXPath($dom);
// Query for the a link using xpath
$items = $xpath->query("//td[1]/div/div[1]/a");
// If we find something using that query
if($items->length)
{
// Output each item
foreach($items as $item)
echo $item->nodeValue . " - " . $item->getAttribute("href") . "<br />";
}
Pull recent news items from external site with no rss feed - preg_match()? [closed]
-
06-10-2022 - |
Вопрос
I am trying to pull the latest 4 news items from this site here: http://www.wolverinegreen.com/sports/m-wrestl/spec-rel/utva-m-wrestl-spec-rel.html
They have no rss feed, so I have been reading into using php preg_match function but the syntax is a little confusing and I am not sure exactly how to do it. Any suggestions would be truly appreciated or if there is a more efficient method that I have not thought of then I am open to ideas.
Решение
Не связан с StackOverflow