Snoopyis a PHP class that simulates a web browser. It automates the task of retrieving web page content and posting forms, for example. Some of Snoopy's features include: easily fetch the contents of a web page, easily fetch the text from a web page (strip html tags), easily fetch the the links from a web page, supports proxy hosts, supports basic user/pass authentication, supports setting user_agent, referer, cookies and header content, supports browser redirects, and controlled depth of redirects, expands fetched links to fully qualified URLs (default), and easily submit form data and retrieve the results.
Snoopy ก็เป็น Class สำหรับจำลองเป็น Web Browser สำหรับไปดึง contents จากเว็บไซค์มาแสดงผลหรือใช้งานต่อไป
ใน readme มีตัวอย่างการใช้งาน เอามาแปะให้ดูซะเลย
CODE
include "Snoopy.class.php";
$snoopy = new Snoopy;
$snoopy->fetchtext("http://www.php.net/");
print $snoopy->results;
$snoopy->fetchlinks("http://www.phpbuilder.com/");
print $snoopy->results;
$submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";
$submit_vars["q"] = "amiga";
$submit_vars["submit"] = "Search!";
$submit_vars["searchhost"] = "Altavista";
$snoopy->submit($submit_url,$submit_vars);
print $snoopy->results;
$snoopy->maxframes=5;
$snoopy->fetch("http://www.ispi.net/");
echo htmlentities($snoopy->results[0]);
echo htmlentities($snoopy->results[1]);
echo htmlentities($snoopy->results[2]);
$snoopy->fetchform("http://www.altavista.com");
print $snoopy->results;