Skip to main content

Posts

Showing posts with the label URL

Fetch Meta Data from URL using PHP and Ajax

In this tutorial am going to explain how to get meta data from an URL to display in website. It’s similar to URL data extracting. You can see this example most of social networking sites like Facebook and Google Plus. It also called as Extracting data from URL using Jquery, Ajax and PHP. I have used get_meta_tags PHP function to get the Meta data from URL. This is a PHP in built function. The output will be returned in array. $url=get_meta_tags("http://www.webinfopedia.com/"); This will give you an array of all Meta data like Description, Keyword, Author, Copyright, Robot etc… Now you need to display it like below. echo ($url["description"]); echo substr($url["keywords"], 0, 128); echo ($url["copyright"]); To get the title tag form URL am using file_get_contents function. echo get(file_get_contents('http://www.webinfopedia.com/'), ""); //get function function get($a,$b,$c) ...

Adding SSL and HTTPS in WordPress

Present days, SSL is important for every type of websites. It helps to make your website secure and earn the trust of your website’s visitors. Besides this, SSL certificate and HTTPS boosts your website ranking on various search engines. So, if you don’t have already added SSL to your website, it’s time to move from HTTP to HTTPS. Are you want to move from HTTP to HTTPS and install an SSL certificate in WordPress site? This step-by-step guide will make it easier to add SSL to website . In this tutorial, we will show you how to add SSL and HTTPS in WordPress . What are SSL and HTTPS? SSL (Secure Sockets Layer) creates an encrypted layer when data passed between two systems. Whether it is server to server or server to browser communication, SSL encrypts the data to make it secure. SSL and HTTPS both are used to protect the online data by creating a secure connection between browser and server. SSL – Transport Layer Security protocol that provides communications security over a network. ...

Get YouTube Video Thumbnail Image URL using PHP

In the present day, YouTube embed video is used on many websites. Many web project needs to implement a YouTube video gallery where YouTube video thumbnails are dynamically listed in the gallery. In this article, we’ll provide the short PHP snippet to get YouTube video thumbnail image URL using PHP. This simple PHP script is very useful when you want to get the YouTube video thumbnail image URL dynamically based on the provided YouTube URL. Using this YouTube thumbnail URL, you can design the video gallery as per your project needs. Get Thumbnail Image URL from YouTube Embed Code The following PHP code extracts the src value from YouTube Embed Code and generates the video thumbnail image URL based on YouTube video ID. $embedCode = '<iframe width="560" height="315" src="https://www.youtube.com/embed/dwJasig9Olw" frameborder="0" allowfullscreen></iframe>'; preg_match('/src="([^"]+)"/', $embedCode, $match)...

How to Extract All URLs from a Web Page using PHP

Extract URLs from the website is used in many cases, generating a sitemap from website URL is one of them. You can easily get all URLs from a web page using PHP. Here we’ll provide short and simple code snippets to extract all URLs from a web page in PHP. The following PHP code helps to get all the links from a web page URL. The file_get_contents() function is used to get webpage content from URL. Fetched web page content is stored in $urlContent variable. All the URLs or links are extracted from web page HTML content using DOMDocument class. All links will validate using FILTER_VALIDATE_URL before return and print if it is a valid URL. $urlContent = file_get_contents('http://php.net'); $dom = new DOMDocument(); @$dom->loadHTML($urlContent); $xpath = new DOMXPath($dom); $hrefs = $xpath->evaluate("/html/body//a"); for($i = 0; $i < $hrefs->length; $i++){ $href = $hrefs->item($i); $url = $href->getAttribute('href'); $url = filter...

Generate SEO Friendly URL from String in PHP

Uses of the SEO friendly URL helps to improve the search engine ranking. Also, the search engine friendly URL gives an idea about the web page content. The different between normal URL and SEO friendly URL is given below. Noraml URL: http://www.example.com/posts.php?id=123 SEO URL: http://www.example.com/php-tutorial-for-beginners It clearly shows that the SEO URL is more human-friendly than the normal URL. From SEO URL the user can get a clear idea on what will be on the web page they are clicking. If you want to increase your website ranking on Search Engines and make more user-friendly, you need to switch to the SEO friendly URL. In this tutorial, we’ll show you how to generate SEO friendly URL from string using PHP . Our example script makes it easy to convert title string to SEO friendly URL in PHP . We’ve grouped together all the PHP code into a function named generateSeoURL() . The generateSeoURL() function automatically create clean and SEO friendly URL slug from string. PHP...

How to Capture Screenshot of Website from URL using PHP

Web page screenshot capture functionality is used for various purposes in the web application. There are many third party APIs are available to take a screenshot of the website. But if you wish to build your own script to get a screenshot from URL , you can do it easily using PHP and Google PageSpeed Insights API. Generally, Google PageSpeed Insights API is used to measure the performance of a web page. But you can also use Google PageSpeed Insights API to get a screenshot of the website from URL. In this tutorial, we will show you how to capture a screenshot of the website from URL using Google PageSpeed Insights API and PHP . The following example script takes a screenshot of the website by the URL and shows as an image. Get Screenshot of Website from URL To make web page snapshot, Google PageSpeed Insights API need to be called with the following params. url: specify the URL of the website. screenshot: specify screenshot=true to retrieve the screenshot data. //website url $siteUR...

Find links from URL in PHP

Hi everybody. In this article I will show you how to get all the links from an URL. I have used simple DOM concept to find the html data from URL. file_get_contents and loadHTML is used to retrieve the html for URL and DOMXPath to grab it. Find this code snippet below. PHP code below //URL $srcUrl='http://www.webinfopedia.com/'; $html = file_get_contents($srcUrl); $dom = new DOMDocument(); @$dom->loadHTML($html); // grab all the on the page $xpath = new DOMXPath($dom); //finding the a tag $hrefs = $xpath->evaluate("/html/body//a"); //Loop to display all the links for ($i = 0; $i < $hrefs->length; $i++) { $href = $hrefs->item($i); $url = $href->getAttribute('href'); //Filter the null links if($url!='#') { echo "".$url." "; } } Hope that this article will help you