function looseDict($keyword)
{
$bot = new Bot();
$keyword = str_replace(' ', '+', $keyword);
$data = $bot->get('http://dictionary.reference.com/browse/' . $keyword);
$content = $this->strip_dict($data, $keyword);
return $content;
}
function strip_dict($content, $keyword)
{
// check if there is an entry found...
if(strpos($content, '<h1>No results found for <em>') != FALSE)
{
$dictionary = '';
}
else {
preg_match('/<span class="pg">(.*)<\/span>/', $content, $matches);
$pos = trim(strip_tags($matches[1]));
preg_match("/<table class=\"luna-Ent\"><tr><td valign=\"top\" class=\"dn\">1.<\/td><td valign=\"top\">(.*)<\/td><\/tr><\/table>/", $content, $matches);
$def = trim(strip_tags($matches[1]));
$dictionary = '<em>from dictionary.com...</em><br /><strong>' . $keyword . '</strong> - <em>' . $pos . '</em> - ' . $def . '<br /><br />';
/*FORMAT:<span class="pg">–noun </span><table class="luna-Ent"><tr><td valign="top" class="dn">1.</td><td valign="top">the means by which the presence, quality, or genuineness of anything is determined; a means of trial. </td></tr></table>*/
}
return $dictionary;
}
function looseWiki($keyword)
{
$bot = new Bot();
$keyword = str_replace(' ','+',$keyword);
$data = $bot->get("http://www.google.com/search?q=site:wikipedia.org+$keyword");
$term = $bot->getVal('/en.wikipedia.org\/wiki\/(.*?)"/',$data);
$wiki = $bot->get("http://en.wikipedia.org/wiki/$term");
/*$content = strip_tags($wiki);
$content = str_replace(array(1,2,3,4,5,6,7,8,9,0,'[',']','edit'),'',$content);
$content = str_replace('[edit]','',$content);
*/
$content = $this->strip_wiki($wiki);
return $content;
//bodyContent
}