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.
- 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 ); echo $second_step;
- 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.
Articles Related to Programming:
- How to Create Website Layout Using HTML Frameset.
- How to Add CKEditor to PHP Page Step By Step Tutorial.
- How to Create Unique ID for Each Device By Using Javscript.