pinggu

http://eve.vip-esp.com/README

Oct 24th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.87 KB | None | 0 0
  1. NAME:
  2.  
  3. Snoopy - the PHP net client v2.0.0
  4.  
  5. SYNOPSIS:
  6.  
  7. include "Snoopy.class.php";
  8. $snoopy = new Snoopy;
  9.  
  10. $snoopy->fetchtext("http://www.php.net/");
  11. print $snoopy->results;
  12.  
  13. $snoopy->fetchlinks("http://www.phpbuilder.com/");
  14. print $snoopy->results;
  15.  
  16. $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";
  17.  
  18. $submit_vars["q"] = "amiga";
  19. $submit_vars["submit"] = "Search!";
  20. $submit_vars["searchhost"] = "Altavista";
  21.  
  22. $snoopy->submit($submit_url,$submit_vars);
  23. print $snoopy->results;
  24.  
  25. $snoopy->maxframes=5;
  26. $snoopy->fetch("http://www.ispi.net/");
  27. echo "<PRE>\n";
  28. echo htmlentities($snoopy->results[0]);
  29. echo htmlentities($snoopy->results[1]);
  30. echo htmlentities($snoopy->results[2]);
  31. echo "</PRE>\n";
  32.  
  33. $snoopy->fetchform("http://www.altavista.com");
  34. print $snoopy->results;
  35.  
  36. DESCRIPTION:
  37.  
  38. What is Snoopy?
  39.  
  40. Snoopy is a PHP class that simulates a web browser. It automates the
  41. task of retrieving web page content and posting forms, for example.
  42.  
  43. Some of Snoopy's features:
  44.  
  45. * easily fetch the contents of a web page
  46. * easily fetch the text from a web page (strip html tags)
  47. * easily fetch the the links from a web page
  48. * supports proxy hosts
  49. * supports basic user/pass authentication
  50. * supports setting user_agent, referer, cookies and header content
  51. * supports browser redirects, and controlled depth of redirects
  52. * expands fetched links to fully qualified URLs (default)
  53. * easily submit form data and retrieve the results
  54. * supports following html frames (added v0.92)
  55. * supports passing cookies on redirects (added v0.92)
  56.  
  57.  
  58. REQUIREMENTS:
  59.  
  60. Snoopy requires PHP with PCRE (Perl Compatible Regular Expressions),
  61. and the OpenSSL extension for fetching HTTPS requests.
  62.  
  63. CLASS METHODS:
  64.  
  65. fetch($URI)
  66. -----------
  67.  
  68. This is the method used for fetching the contents of a web page.
  69. $URI is the fully qualified URL of the page to fetch.
  70. The results of the fetch are stored in $this->results.
  71. If you are fetching frames, then $this->results
  72. contains each frame fetched in an array.
  73.  
  74. fetchtext($URI)
  75. ---------------
  76.  
  77. This behaves exactly like fetch() except that it only returns
  78. the text from the page, stripping out html tags and other
  79. irrelevant data.
  80.  
  81. fetchform($URI)
  82. ---------------
  83.  
  84. This behaves exactly like fetch() except that it only returns
  85. the form elements from the page, stripping out html tags and other
  86. irrelevant data.
  87.  
  88. fetchlinks($URI)
  89. ----------------
  90.  
  91. This behaves exactly like fetch() except that it only returns
  92. the links from the page. By default, relative links are
  93. converted to their fully qualified URL form.
  94.  
  95. submit($URI,$formvars)
  96. ----------------------
  97.  
  98. This submits a form to the specified $URI. $formvars is an
  99. array of the form variables to pass.
  100.  
  101.  
  102. submittext($URI,$formvars)
  103. --------------------------
  104.  
  105. This behaves exactly like submit() except that it only returns
  106. the text from the page, stripping out html tags and other
  107. irrelevant data.
  108.  
  109. submitlinks($URI)
  110. ----------------
  111.  
  112. This behaves exactly like submit() except that it only returns
  113. the links from the page. By default, relative links are
  114. converted to their fully qualified URL form.
  115.  
  116.  
  117. CLASS VARIABLES: (default value in parenthesis)
  118.  
  119. $host the host to connect to
  120. $port the port to connect to
  121. $proxy_host the proxy host to use, if any
  122. $proxy_port the proxy port to use, if any
  123. proxy can only be used for http URLs, but not https
  124. $agent the user agent to masqerade as (Snoopy v0.1)
  125. $referer referer information to pass, if any
  126. $cookies cookies to pass if any
  127. $rawheaders other header info to pass, if any
  128. $maxredirs maximum redirects to allow. 0=none allowed. (5)
  129. $offsiteok whether or not to allow redirects off-site. (true)
  130. $expandlinks whether or not to expand links to fully qualified URLs (true)
  131. $user authentication username, if any
  132. $pass authentication password, if any
  133. $accept http accept types (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*)
  134. $error where errors are sent, if any
  135. $response_code responde code returned from server
  136. $headers headers returned from server
  137. $maxlength max return data length
  138. $read_timeout timeout on read operations (requires PHP 4 Beta 4+)
  139. set to 0 to disallow timeouts
  140. $timed_out true if a read operation timed out (requires PHP 4 Beta 4+)
  141. $maxframes number of frames we will follow
  142. $status http status of fetch
  143. $temp_dir temp directory that the webserver can write to. (/tmp)
  144. $curl_path system path to cURL binary, set to false if none
  145. (this variable is ignored as of Snoopy v1.2.6)
  146. $cafile name of a file with CA certificate(s)
  147. $capath name of a correctly hashed directory with CA certificate(s)
  148. if either $cafile or $capath is set, SSL certificate
  149. verification is enabled
  150.  
  151.  
  152. EXAMPLES:
  153.  
  154. Example: fetch a web page and display the return headers and
  155. the contents of the page (html-escaped):
  156.  
  157. include "Snoopy.class.php";
  158. $snoopy = new Snoopy;
  159.  
  160. $snoopy->user = "joe";
  161. $snoopy->pass = "bloe";
  162.  
  163. if($snoopy->fetch("http://www.slashdot.org/"))
  164. {
  165. echo "response code: ".$snoopy->response_code."<br>\n";
  166. while(list($key,$val) = each($snoopy->headers))
  167. echo $key.": ".$val."<br>\n";
  168. echo "<p>\n";
  169.  
  170. echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  171. }
  172. else
  173. echo "error fetching document: ".$snoopy->error."\n";
  174.  
  175.  
  176.  
  177. Example: submit a form and print out the result headers
  178. and html-escaped page:
  179.  
  180. include "Snoopy.class.php";
  181. $snoopy = new Snoopy;
  182.  
  183. $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";
  184.  
  185. $submit_vars["q"] = "amiga";
  186. $submit_vars["submit"] = "Search!";
  187. $submit_vars["searchhost"] = "Altavista";
  188.  
  189.  
  190. if($snoopy->submit($submit_url,$submit_vars))
  191. {
  192. while(list($key,$val) = each($snoopy->headers))
  193. echo $key.": ".$val."<br>\n";
  194. echo "<p>\n";
  195.  
  196. echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  197. }
  198. else
  199. echo "error fetching document: ".$snoopy->error."\n";
  200.  
  201.  
  202.  
  203. Example: showing functionality of all the variables:
  204.  
  205.  
  206. include "Snoopy.class.php";
  207. $snoopy = new Snoopy;
  208.  
  209. $snoopy->proxy_host = "my.proxy.host";
  210. $snoopy->proxy_port = "8080";
  211.  
  212. $snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)";
  213. $snoopy->referer = "http://www.microsnot.com/";
  214.  
  215. $snoopy->cookies["SessionID"] = 238472834723489l;
  216. $snoopy->cookies["favoriteColor"] = "RED";
  217.  
  218. $snoopy->rawheaders["Pragma"] = "no-cache";
  219.  
  220. $snoopy->maxredirs = 2;
  221. $snoopy->offsiteok = false;
  222. $snoopy->expandlinks = false;
  223.  
  224. $snoopy->user = "joe";
  225. $snoopy->pass = "bloe";
  226.  
  227. if($snoopy->fetchtext("http://www.phpbuilder.com"))
  228. {
  229. while(list($key,$val) = each($snoopy->headers))
  230. echo $key.": ".$val."<br>\n";
  231. echo "<p>\n";
  232.  
  233. echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  234. }
  235. else
  236. echo "error fetching document: ".$snoopy->error."\n";
  237.  
  238.  
  239. Example: fetched framed content and display the results
  240.  
  241. include "Snoopy.class.php";
  242. $snoopy = new Snoopy;
  243.  
  244. $snoopy->maxframes = 5;
  245.  
  246. if($snoopy->fetch("http://www.ispi.net/"))
  247. {
  248. echo "<PRE>".htmlspecialchars($snoopy->results[0])."</PRE>\n";
  249. echo "<PRE>".htmlspecialchars($snoopy->results[1])."</PRE>\n";
  250. echo "<PRE>".htmlspecialchars($snoopy->results[2])."</PRE>\n";
  251. }
  252. else
  253. echo "error fetching document: ".$snoopy->error."\n";
  254.  
  255.  
  256. COPYRIGHT:
  257. Copyright(c) 1999,2000 ispi. All rights reserved.
  258. This software is released under the GNU General Public License.
  259. Please read the disclaimer at the top of the Snoopy.class.php file.
  260.  
  261.  
  262. THANKS:
  263. Special Thanks to:
  264. Peter Sorger <sorgo@cool.sk> help fixing a redirect bug
  265. Andrei Zmievski <andrei@ispi.net> implementing time out functionality
  266. Patric Sandelin <patric@kajen.com> help with fetchform debugging
  267. Carmelo <carmelo@meltingsoft.com> misc bug fixes with frames
Add Comment
Please, Sign In to add comment