Error: Could not fetch http://thedevnet.com/wp-content/plugins/gd-star-rating/css/gdsr.css.php?t=0&s=a10i10m20k20c05r05%23121620243046%23121620243240%23s1pchristmas%23s1pcrystal%23s1pdarkness%23s1poxygen%23s1goxygen_gif%23s1pplain%23s1ppumpkin%23s1psoft%23s1pstarrating%23s1pstarscape%23t1pclassical%23t1pstarrating%23t1gstarrating_gif&ver=1.7.2 for caching. You might need to exclude this file in WP Minify options. The Developer Network – Snoopy PHP Net Client

Snoopy PHP Net Client

This PHP class simulates being a web browser. It can post forms, read links, spoof referrers (helpful for accessing hotlink protected content), and a hell of alot more.

Some features:

  • 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)
  • easily submit form data and retrieve the results
  • supports following html frames (added v0.92)
  • supports passing cookies on redirects (added v0.92)

Insert First (Initialize):

  1. <?
  2.  // creates the snoopy class object
  3.  // http://thedevnet.com/php/classes/snoopy-php-net-client/
  4.  
  5.  include "Snoopy.class.php";
  6.  $snoopy = new Snoopy;
  7. ?>

Example (fetch a web page and display the return headers and content):

  1. <?
  2.  // remember to already have the class included and object created
  3.  $snoopy->user = "joe";
  4.  $snoopy->pass = "bloe";
  5.  
  6.  if($snoopy->fetch("http://www.slashdot.org/"))
  7.  {
  8.   echo "response code: ".$snoopy->response_code."<br>\n";
  9.   while(list($key,$val) = each($snoopy->headers))
  10.    echo $key.": ".$val."<br>\n";
  11.   echo "<p>\n";
  12.  
  13.   echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  14.  }
  15.  else
  16.   echo "error fetching document: ".$snoopy->error."\n";
  17. ?>

Example (submit a form and print out the result headers and content):

  1. <?
  2.  // remember to already have the class included and object created
  3.  $submit_url = "http://lnk.ispi.net/texis/scripts/msearch/netsearch.html";
  4.  
  5.  $submit_vars["q"] = "amiga";
  6.  $submit_vars["submit"] = "Search!";
  7.  $submit_vars["searchhost"] = "Altavista";
  8.  
  9.  
  10.  if($snoopy->submit($submit_url,$submit_vars))
  11.  {
  12.   while(list($key,$val) = each($snoopy->headers))
  13.    echo $key.": ".$val."<br>\n";
  14.   echo "<p>\n";
  15.  
  16.   echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  17.  }
  18.  else
  19.   echo "error fetching document: ".$snoopy->error."\n";
  20. ?>

Example (functionality):

  1. <?
  2.  // remember to already have the class included and object created
  3.  $snoopy->proxy_host = "my.proxy.host";
  4.  $snoopy->proxy_port = "8080";
  5.  
  6.  $snoopy->agent = "(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)";
  7.  $snoopy->referer = "http://www.microsnot.com/";
  8.  
  9.  $snoopy->cookies["SessionID"] = 238472834723489l;
  10.  $snoopy->cookies["favoriteColor"] = "RED";
  11.  
  12.  $snoopy->rawheaders["Pragma"] = "no-cache";
  13.  
  14.  $snoopy->maxredirs = 2;
  15.  $snoopy->offsiteok = false;
  16.  $snoopy->expandlinks = false;
  17.  
  18.  $snoopy->user = "joe";
  19.  $snoopy->pass = "bloe";
  20.  
  21.  if($snoopy->fetchtext("http://www.phpbuilder.com"))
  22.  {
  23.   while(list($key,$val) = each($snoopy->headers))
  24.    echo $key.": ".$val."<br>\n";
  25.   echo "<p>\n";
  26.  
  27.   echo "<PRE>".htmlspecialchars($snoopy->results)."</PRE>\n";
  28.  }
  29.  else
  30.   echo "error fetching document: ".$snoopy->error."\n";
  31. ?>

Example (framed content):

  1. <?
  2.  // remember to already have the class included and object created
  3.  $snoopy->maxframes = 5;
  4.  
  5.  if($snoopy->fetch("http://www.ispi.net/"))
  6.  {
  7.   echo "<PRE>".htmlspecialchars($snoopy->results[0])."</PRE>\n";
  8.   echo "<PRE>".htmlspecialchars($snoopy->results[1])."</PRE>\n";
  9.   echo "<PRE>".htmlspecialchars($snoopy->results[2])."</PRE>\n";
  10.  }
  11.  else
  12.   echo "error fetching document: ".$snoopy->error."\n";
  13. ?>
Snoopy The PHP Net Client
Snoopy-1.2.4.zip
Version: 1.2.4

23.7 KiB
21 Downloads
Details…

GD Star Rating
loading...

Originally posted 2009-10-17 21:44:26.

Popularity: 49%

Posted by irbobo   @   17 August 2010

Like this post? Share it!

RSS Digg Twitter StumbleUpon Delicious Technorati Facebook

0 Comments

No comments yet. Be the first to leave a comment !
Leave a Comment

You must be logged in to post a comment.

Previous Post
« Constrained Image Resize Min/Max Values
Next Post
Image Captcha Spam Prevention »
Powered by Wordpress   |   Lunated designed by ZenVerse