본문 바로가기
프로그램.코딩

Snoopy 소켓 클래스 라이브러리

by landzz 2007. 9. 20.

http://sourceforge.net/projects/snoopy/

소켓함수를 사용한다거나...외부링크를 가져오거나.. 외부로 폼을 전송시킬때 유용할듯.
소스포지의 설명

Snoopy is a PHP class that simulates a web browser.
it automates the task of retrieving web page content and posting forms 라..ㅎㅎ

 
참고해서 볼만한 포스팅

http://toyobi.net/web/59
http://njey.goanygate.com/tt/113

 

 

-README EXAMPLES:

 Example:  fetch a web page and display the return headers and
    the contents of the page (html-escaped):
 
 include "Snoopy.class.php";
 $snoopy = new Snoopy;
 
 $snoopy->user = "joe";
 $snoopy->pass = "bloe";
 
 if($snoopy->fetch("
http://www.slashdot.org/"))
 {
  echo "response code: ".$snoopy->response_code."<br>\n";
  while(list($key,$val) = each($snoopy->headers))
   echo $key.": ".$val."<br>\n";
  echo "<p>\n";
 
  echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
 }
 else
  echo "error fetching document: ".$snoopy->error."\n";


 Example: submit a form and print out the result headers
    and html-escaped page:

 include "Snoopy.class.php";
 $snoopy = new Snoopy;
 
 $submit_url = "
http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";
 
 $submit_vars["q"] = "amiga";
 $submit_vars["submit"] = "Search!";
 $submit_vars["searchhost"] = "Altavista";

 
 if($snoopy->submit($submit_url,$submit_vars))
 {
  while(list($key,$val) = each($snoopy->headers))
   echo $key.": ".$val."<br>\n";
  echo "<p>\n";
 
  echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
 }
 else
  echo "error fetching document: ".$snoopy->error."\n";


 Example: showing functionality of all the variables:
 

 include "Snoopy.class.php";
 $snoopy = new Snoopy;

 $snoopy->proxy_host = "my.proxy.host";
 $snoopy->proxy_port = "8080";
 
 $snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)";
 $snoopy->referer = "
http://www.microsnot.com/";
 
 $snoopy->cookies["SessionID"] = 238472834723489l;
 $snoopy->cookies["favoriteColor"] = "RED";
 
 $snoopy->rawheaders["Pragma"] = "no-cache";
 
 $snoopy->maxredirs = 2;
 $snoopy->offsiteok = false;
 $snoopy->expandlinks = false;
 
 $snoopy->user = "joe";
 $snoopy->pass = "bloe";
 
 if($snoopy->fetchtext("
http://www.phpbuilder.com"))
 {
  while(list($key,$val) = each($snoopy->headers))
   echo $key.": ".$val."<br>\n";
  echo "<p>\n";
 
  echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
 }
 else
  echo "error fetching document: ".$snoopy->error."\n";


 Example:  fetched framed content and display the results
 
 include "Snoopy.class.php";
 $snoopy = new Snoopy;
 
 $snoopy->maxframes = 5;
 
 if($snoopy->fetch("
http://www.ispi.net/"))
 {
  echo "<PRE>".htmlspecialchars($snoopy->results[0])."</PRE>\n";
  echo "<PRE>".htmlspecialchars($snoopy->results[1])."</PRE>\n";
  echo "<PRE>".htmlspecialchars($snoopy->results[2])."</PRE>\n";
 }
 else
  echo "error fetching document: ".$snoopy->error."\n";


'프로그램.코딩' 카테고리의 다른 글

INSERT ... SELECT Syntax  (0) 2007.11.05
Oracle 페이징,리스팅,인덱스  (0) 2007.10.22
플래시8을 이용한 업로더..  (0) 2007.09.03
단순쿼리브라우져..  (0) 2007.08.30
mysql Dump 용 간단스크립제작  (0) 2007.08.24

댓글