14 May 2024
I was developing a SEO tool, where I needed to gather information about websites title and description.$html = file_get_contents($url);
$doc = new \DOMDocument();
$doc->loadHTML($html);
$nodes = $doc->getElementsByTagName('title');
$title = $nodes->item(0)->nodeValue;
Using this method we can also continue our data collection and grab the description or other metadata. This can be achieved like this:
$metas = $doc->getElementsByTagName('meta');
for ($i = 0; $i < $metas->length; $i++)
{
$meta = $metas->item($i);
if ($meta->getAttribute('name') == 'description')
{
$description = $meta->getAttribute('content');
}
}
The Seven Restful Controller Actions in Laravel
Published 2024-05-05 — Updated 2024-05-16
Laravel
PHP
Web development
The seven RESTful actions and how you could implement them in Laravel
Read the post →Simplifying Your Code with Advanced Operators in PHP
Published 2024-05-05
PHP
Web development
Ready to write PHP code like a pro? Learn how to use advanced operators to make your code more concise and readable, and take your skills to the next level.
Read the post →Useful Laravel packages
Published 2024-05-05
Laravel
PHP
Web development
Learn what packages that can help you build even better websites in Laravel. We'll go trhough the must-haves and packages that are just nice to have.
Read the post →