<?php
/**
* WiseLoop PHP Web Grabber Sample<br/>
* Title: Freedigitalphotos.net Search
* Description: Get Freedigitalphotos Images
* Searching freedigitalphotos.net images and displaying the results within your own page
*/
//get the search phrase
$q = str_replace(" ", "+", wlExtArray::getArrayValue($_POST, "q", wlExtArray::getArrayValue($_GET, "q", "")));
//get the page
$p = intval(wlExtArray::getArrayValue($_POST, "p", wlExtArray::getArrayValue($_GET, "p", 1)));
?>
<!-- form start -->
<form action="" id="form" method="POST" enctype="multipart/form-data" class="form-horizontal" role="form">
<input type="hidden" id="demo" name="demo" value="flickr"/>
<div class="form-group">
<label for="q" class="col-sm-2 control-label">Search Photos:</label>
<div class="col-sm-10">
<input class="form-control" type="text" name="q" id="q" placeholder="Search" value="<?php echo $q != "" ? $q : "school"; ?>"/>
</div>
</div>
<div class="form-group">
<label for="p" class="col-sm-2 control-label">Page:</label>
<div class="col-sm-10">
<select class="form-control" name="p" id="p" onchange="document.forms['form'].submit();">;
<?php
for ($i = 1; $i < 10; $i++)
echo '<option ' . ($p == $i ? 'selected' : '') . ' value="' . $i . '">' . $i . '</option>';
?>
</select>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<input type="submit" value="Image Search" class="btn btn-primary"/>
</div>
</div>
</form>
<!-- form end -->
<?php
if ($q) {
//compute the url using the given search phrase and page
$url = 'http://www.freedigitalphotos.net/images/search.php?search=' . $q . '&p=' . $p;
$prm = new wlWgParam('negative-margin');
$prm->setRemoveTags(array('gallerypagenav'));
$prm->setReplaceStrings(array(
'search' => array('gallery-thumbnails.php?id='),
'replace' => array('http://www.freedigitalphotos.net/images/gallery-thumbnails.php?id=')
));
$prm->setStripTags(array('<a'));
$prm->setRemoveTags(array('<h'));
//here is the magic: creating the Freedigitalphotos Search grabber processor object using the computed url and tag to extract
$wp = new wlWgProcessor(
$url, //the targeted real url
$prm, //the grabbing parameter
0 //no caching needed - it's a search engine :)
);
$result = $wp->get();
//grab and draw the contents
//$wp->draw();
echo '<div class="well well-small">';
echo '<h3 class="color-caption">Grabbed content from <a style="font-weight:bold;" target="_blank" href="' . $url . '">' . $url . '</a></h3>';
echo $result[0][0];
echo '</div>';
}