Supposing you are web programmer and want to provide your customers a list of website templates to choose from.
The templates list has to be displayed within your own website.
This can be done in many ways such as:
Grabbing, extractig and embedding HTML content form websites are the things that WiseLoop PHP Web Grabber is about.
WiseLoop PHP Web Grabber is a set of PHP classes designed to extract HTML content form the web.
This package allows complex content extraction in a flexible manner, by using only a few lines of code.
The extraction can be made from any web URL or local file; the desired content to be grabbed can be a full web page or a set of tags that can even have incomplete specifications.
For more information please checkout the product page at http://wiseloop.com/product/php-web-grabber
The FreeWebsiteTemplates.com site shows:
After a careful study of the source code, you are able to identify the tag that contains the actual list of templates that you want to extract and display it inside your website.
The targeted tag will be:
<div id="leftside">
Obviously this tag contains a lots of other stuff that you don't need and don't want to be displayed in your website such as:
Also, there are some styles and CSS clases that will not make any sense once you have displayed that content into your website; most likely you have not defined such CSS styles into your site CSS:
You will use the PHP Web Grabber tag based extraction engine to grab the targeted tag contents, the tag removal feature to remove the unwanted content and the string replacement feature to modify the CSS styles accordingly to your website CSS styles.
All you need to do is to create a wlWgProcessor object and pass to it some needed parameters consisting of:
Your code should be something like this:
$grabber = new wlWgProcessor( "http://www.freewebsitetemplates.com/", //the targeted real url new wlWgParam( '<div id="leftside">', //the desired tag to be extracted array( "search" => array( //needles ... 'class="title"', 'class="ss"', 'class="download"', 'class="preview"', 'class="getwix"', 'class="templateleft"', 'class="templateright"', ), "replace" => array( //replaces ... 'class="your-title-class"', 'class="your-ss-class"', 'class="your-download-class"', 'class="your-preview-class"', 'class="your-getwix-class"', 'class="your-templateleft-class"', 'class="your-templateright-class"', ) ), array( //remove tags and their contents that contains ... '<h1>', //all the <h1> tags including the Free Website Templates header text '<div class="pages"', //the pages links '<div class="about">', //the upper paragraph starting with "Website templates are pre-designed websites ..." '<div style="clear:', //some empty div tag: note that this tag is incomplete, it will remove <div style="clear:both;"> and <div style="clear"> '<div class="clear">', //some empty div tag '<div style="margin-left:31px;display:block;">', //the Previousa, Next links and the bottom paragraph starting with "All free website templates have been coded ..." '<div class="templatedaily">' //the Template of the day header ) ), wlWgConfig::CACHE_TIME_1_WEEK //the caching time (expressed in minutes) ); $grabber->draw(); //print out the extracted processed content
At this point you can realize that WiseLoop PHP Web Grabber is a powerfull tool that can help you develop complex API-s for various service-type websites.
You could wrap the code above into a nice class that can behave like a native API for FreeWesiteTemplates.com.
class wlWgFreeWebsiteTemplatesDotCom extends wlWgProcessor { public function __construct() { parent::__construct( "http://www.freewebsitetemplates.com/", //the targeted real url new wlWgParam( '<div id="leftside">', //the desired tag to be extracted array( "search" => array( //needles ... 'class="title"', 'class="ss"', 'class="download"', 'class="preview"', 'class="getwix"', 'class="templateleft"', 'class="templateright"', ), "replace" => array( //replaces ... 'class="your-title-class"', 'class="your-ss-class"', 'class="your-download-class"', 'class="your-preview-class"', 'class="your-getwix-class"', 'class="your-templateleft-class"', 'class="your-templateright-class"', ) ), array( //remove tags and their contents that contains ... '<h1>', //all the <h1> tags including the Free Website Templates header text '<div class="pages"', //the pages links '<div class="about">', //the upper paragraph starting with "Website templates are pre-designed websites ..." '<div style="clear:', //some empty div tag: note that this tag is incomplete, it will remove <div style="clear:both;"> and <div style="clear"> '<div class="clear">', //some empty div tag '<div style="margin-left:31px;display:block;">', //the Previousa, Next links and the bottom paragraph starting with "All free website templates have been coded ..." '<div class="templatedaily">' //the Template of the day header ) ), wlWgConfig::CACHE_TIME_1_WEEK //the caching time (expressed in minutes) ); } } $grabber = new wlWgFreeWebsiteTemplatesDotCom(); //create the FreeWebsiteTemplates API object $grabber->draw(); //print out the extracted processed content
Please chekout the full example provided in the package that supports the pagination feature also.
If you want to retrieve various contents from a public web site and display them on your site, PHP Web Grabber is the perfect tool that will help you do that.
No frames or iframes involved! Real HTML content, grabbed form the web and displayed in whithin your webpage just like it was generated by your site.