Know about Technology!

Responsive Ads Here

Saturday, February 10, 2018

How to Grab Other Website Content Using PHP Curl

Fetch Other Website Content Using PHP

Introduction:

Hello guys. Today I am going to introduce a PHP Programming code which will help you to grab other website content to your website without let your visitors know about the grabbing. I used the programming for creating Live Cricket Score Website and News Website. So let's get in to the tutorial.

About CURL in PHP Programming: 

The cURL library (or, 'libcurl' which is the package name on the server) is often used in PHP to access data from outside web pages. Common uses include reading rss feeds or accessing third-party API systems. libcurl currently supports the http, https, ftp, gopher, telnet, dict, file, and ldap protocols.

How to Grab Other Website Content Using CURL in PHP?

It is very easy to grab other website content using CURL PHP. There is different method available to do this. Just follow the steps that given below.
$html=file_get_contents("http://www.somewebsite.com") 
  • The above code will help you to bring the whole website content to your web page. You can use the above code to display an offer page or something from other website. In order to display the content, You have to echo the $html variable.
$url = 'https://somedomain.com/somesite/';
$content = file_get_contents($url);
$first_step = explode( '<div id="thediv">' , $content );
$second_step = explode("</div>" , $first_step[1] );

echo $second_step[0];
  • The above code will helps you to pull other website content area wise. Example: You can pull just an area which display score board. Replace the <div id="thediv"> with the other website div class id which you want to display on your website.
There is lot's of other things which We can do with the CURL in PHP Programming. Example Applications like Search Engine Spider, CMS Updater, Etc are developing with the CURL. Work with the above code and give us your feedback.

No comments:

Post a Comment