แนะนำ Snoopy


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;
คำสำคัญ (Tags): #php#snoopy
หมายเลขบันทึก: 18802เขียนเมื่อ 14 มีนาคม 2006 14:06 น. ()แก้ไขเมื่อ 11 กุมภาพันธ์ 2012 14:32 น. ()สัญญาอนุญาต: จำนวนที่อ่านจำนวนที่อ่าน:


ความเห็น (0)

ไม่มีความเห็น

พบปัญหาการใช้งานกรุณาแจ้ง LINE ID @gotoknow
ClassStart
ระบบจัดการการเรียนการสอนผ่านอินเทอร์เน็ต
ทั้งเว็บทั้งแอปใช้งานฟรี
ClassStart Books
โครงการหนังสือจากคลาสสตาร์ท