PHPackages                             purcaholic/snoopy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. purcaholic/snoopy

Abandoned → [purc/snoopy](/?search=purc%2Fsnoopy)Php-net-client[HTTP &amp; Networking](/categories/http)

purcaholic/snoopy
=================

Snoopy - the PHP net client

041PHP

Since Nov 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/purcaholic/Snoopy)[ Packagist](https://packagist.org/packages/purcaholic/snoopy)[ RSS](/packages/purcaholic-snoopy/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

NAME:
=====

[](#name)

Snoopy - the PHP net client v2.0.0 (adapted to PHP 8.2)

SYNOPSIS:
---------

[](#synopsis)

```
$snoopy = new \Purc\Snoopy\Snoopy();

$snoopy->fetchtext('https://www.google.com/');
echo 'fetchtext: ' . print_r($snoopy->results, true);

$snoopy->fetchlinks('https://www.phpbuilder.com/');
echo 'fetchlinks: ' . print_r($snoopy->results, true);

$url = 'https://www.php.net/search.php';
$vars = [
    'show' => 'quickref',
    'pattern' => 'PHP',
];
$snoopy->submit($url, $vars);
echo 'submit: ' . print_r($snoopy->results, true);

$snoopy->fetchform('https://www.altavista.com');
echo 'fetchform: ' . print_r($snoopy->results, true);
```

DESCRIPTION:
------------

[](#description)

What is Snoopy?

Snoopy is 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:

- easily fetch the contents of a web page
- easily fetch the text from a web page (strip html tags)
- easily fetch 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)

REQUIREMENTS:
-------------

[](#requirements)

Snoopy requires PHP with PCRE (Perl Compatible Regular Expressions), and the OpenSSL extension for fetching HTTPS requests.

CLASS METHODS:
--------------

[](#class-methods)

### `fetch($uri)`

[](#fetchuri)

This is the method used for fetching the contents of a web page. `$uri` is the fully qualified URL of the page to fetch. The results of the fetch are stored in $this-&gt;results. If you are fetching frames, then $this-&gt;results contains each frame fetched in an array.

### `fetchtext($uri)`

[](#fetchtexturi)

This behaves exactly like `fetch()` except that it only returns the text from the page, stripping out html tags and other irrelevant data.

### `fetchform($uri)`

[](#fetchformuri)

This behaves exactly like `fetch()` except that it only returns the form elements from the page, stripping out html tags and other irrelevant data.

### `fetchlinks($uri)`

[](#fetchlinksuri)

This behaves exactly like `fetch()` except that it only returns the links from the page. By default, relative links are converted to their fully qualified URL form.

### `submit($uri, $formVars)`

[](#submituri-formvars)

This submits a form to the specified `$uri`. `$formVars` is an array of the form variables to pass.

### `submittext($uri, $formVars)`

[](#submittexturi-formvars)

This behaves exactly like `submit()` except that it only returns the text from the page, stripping out html tags and other irrelevant data.

### `submitlinks($uri)`

[](#submitlinksuri)

This behaves exactly like `submit()` except that it only returns the links from the page. By default, relative links are converted to their fully qualified URL form.

CLASS VARIABLES: (default value in parenthesis)
-----------------------------------------------

[](#class-variables----default-value-in-parenthesis)

```
$host             the host to connect to
$port             the port to connect to
$proxy_host       the proxy host to use, if any
$proxy_port       the proxy port to use, if any
                  proxy can only be used for http URLs, but not https
$agent            the user agent to masqerade as (Snoopy v0.1)
$referer          referer information to pass, if any
$cookies          cookies to pass if any
$rawheaders       other header info to pass, if any
$maxredirs        maximum redirects to allow. 0=none allowed. (5)
$offsiteok        whether or not to allow redirects off-site. (true)
$expandlinks      whether or not to expand links to fully qualified URLs (true)
$user             authentication username, if any
$pass             authentication password, if any
$accept           http accept types (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*)
$error            where errors are sent, if any
$response_code    responde code returned from server
$headers          headers returned from server
$maxlength        max return data length
$read_timeout     timeout on read operations (requires PHP 4 Beta 4+)
                  set to 0 to disallow timeouts
$timed_out        true if a read operation timed out (requires PHP 4 Beta 4+)
$maxframes        number of frames we will follow
$status           http status of fetch
$temp_dir         temp directory that the webserver can write to. (/tmp)
$curl_path        system path to cURL binary, set to false if none
                  (this variable is ignored as of Snoopy v1.2.6)
$cafile           name of a file with CA certificate(s)
$capath           name of a correctly hashed directory with CA certificate(s)
                  if either $cafile or $capath is set, SSL certificate
                  verification is enabled
```

EXAMPLES:
---------

[](#examples)

### Example: fetch a web page and display the return headers and the contents of the page (html-escaped):

[](#example-fetch-a-web-page-and-display-the-return-headers-and-the-contents-of-the-page-html-escaped)

```
$snoopy = new \Purc\Snoopy\Snoopy();

$snoopy->user = "joe";
$snoopy->pass = "bloe";

if ($snoopy->fetch("https://www.slashdot.org/"))
{
    echo "response code: " . $snoopy->response_code . "\n";
    while (list($key, $val) = each($snoopy->headers))
    {
        echo $key . ": " . $val . "\n";
    }
    echo "\n";

    echo "" . htmlspecialchars($snoopy->results) . "\n";
}
else
{
    echo "error fetching document: " . $snoopy->error . "\n";
}
```

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

[](#example----submit-a-form-and-print-out-the-result-headers-and-html-escaped-page)

```
$snoopy = new \Purc\Snoopy\Snoopy();

$submit_url = "https://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 . "\n";
    }
    echo "\n";

    echo "" . htmlspecialchars($snoopy->results) . "\n";
}
else
{
    echo "error fetching document: " . $snoopy->error . "\n";
}
```

### Example: showing functionality of all the variables:

[](#example----showing-functionality-of-all-the-variables)

```
$snoopy = new \Purc\Snoopy\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 = "https://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("https://www.phpbuilder.com"))
{
    while (list($key, $val) = each($snoopy->headers))
    {
        echo $key . ": " . $val . "\n";
    }
    echo "\n";

    echo "" . htmlspecialchars($snoopy->results) . "\n";
}
else
{
    echo "error fetching document: " . $snoopy->error . "\n";
}
```

### Example: fetched framed content and display the results

[](#example-fetched-framed-content-and-display-the-results)

```
$snoopy = new \Purc\Snoopy\Snoopy();

$snoopy->maxframes = 5;

if ($snoopy->fetch("https://www.ispi.net/"))
{
    echo "" . htmlspecialchars($snoopy->results[0]) . "\n";
    echo "" . htmlspecialchars($snoopy->results[1]) . "\n";
    echo "" . htmlspecialchars($snoopy->results[2]) . "\n";
}
else
{
    echo "error fetching document: " . $snoopy->error . "\n";
}
```

COPYRIGHT:
----------

[](#copyright)

Copyright(c) 1999,2000 ispi. All rights reserved. This software is released under the GNU General Public License. Please read the disclaimer at the top of the Snoopy.class.php file.

THANKS:
-------

[](#thanks)

Special Thanks to:

- Peter Sorger  help fixing a redirect bug
- Andrei Zmievski  implementing time out functionality
- Patric Sandelin  help with fetchform debugging
- Carmelo  misc bug fixes with frames

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/df5302e512287c34957e26fcedbf086d11a99eea5d622ce987586bce66a87651?d=identicon)[muratpurc](/maintainers/muratpurc)

---

Top Contributors

[![muratpurc](https://avatars.githubusercontent.com/u/323662?v=4)](https://github.com/muratpurc "muratpurc (12 commits)")

---

Tags

clientnetphpphp72snoopy

### Embed Badge

![Health badge](/badges/purcaholic-snoopy/health.svg)

```
[![Health](https://phpackages.com/badges/purcaholic-snoopy/health.svg)](https://phpackages.com/packages/purcaholic-snoopy)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M316](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
