{"id":18054360,"url":"https://github.com/muratpurc/Snoopy","last_synced_at":"2025-03-28T00:33:02.961Z","repository":{"id":62531304,"uuid":"221515550","full_name":"muratpurc/Snoopy","owner":"muratpurc","description":"Snoopy - the PHP net client","archived":false,"fork":false,"pushed_at":"2023-03-16T11:00:34.000Z","size":69,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T02:34:09.017Z","etag":null,"topics":["client","net","php","php72","snoopy"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/muratpurc.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING.lib","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2019-11-13T17:30:07.000Z","updated_at":"2023-01-28T01:16:13.000Z","dependencies_parsed_at":"2023-07-15T18:46:13.765Z","dependency_job_id":null,"html_url":"https://github.com/muratpurc/Snoopy","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"6a3b5afe4614110f18cef3578ca648bd6d47b57d"},"previous_names":["purcaholic/snoopy"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muratpurc%2FSnoopy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muratpurc%2FSnoopy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muratpurc%2FSnoopy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/muratpurc%2FSnoopy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/muratpurc","download_url":"https://codeload.github.com/muratpurc/Snoopy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245949235,"owners_count":20698911,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["client","net","php","php72","snoopy"],"created_at":"2024-10-31T00:10:53.881Z","updated_at":"2025-03-28T00:33:01.983Z","avatar_url":"https://github.com/muratpurc.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NAME:\n\nSnoopy - the PHP net client v2.0.0 (adapted to PHP 8.2)\n\n## SYNOPSIS:\n\n```php\n$snoopy = new \\Purc\\Snoopy\\Snoopy();\n\n$snoopy-\u003efetchtext('https://www.google.com/');\necho 'fetchtext: ' . print_r($snoopy-\u003eresults, true);\n\n$snoopy-\u003efetchlinks('https://www.phpbuilder.com/');\necho 'fetchlinks: ' . print_r($snoopy-\u003eresults, true);\n\n$url = 'https://www.php.net/search.php';\n$vars = [\n    'show' =\u003e 'quickref',\n    'pattern' =\u003e 'PHP',\n];\n$snoopy-\u003esubmit($url, $vars);\necho 'submit: ' . print_r($snoopy-\u003eresults, true);\n\n$snoopy-\u003efetchform('https://www.altavista.com');\necho 'fetchform: ' . print_r($snoopy-\u003eresults, true);\n```\n\n## DESCRIPTION:\n\nWhat is Snoopy?\n\nSnoopy is a PHP class that simulates a web browser. It automates the\ntask of retrieving web page content and posting forms, for example.\n\nSome of Snoopy's features:\n\n* easily fetch the contents of a web page\n* easily fetch the text from a web page (strip html tags)\n* easily fetch the links from a web page\n* supports proxy hosts\n* supports basic user/pass authentication\n* supports setting user_agent, referer, cookies and header content\n* supports browser redirects, and controlled depth of redirects\n* expands fetched links to fully qualified URLs (default)\n* easily submit form data and retrieve the results\n* supports following html frames (added v0.92)\n* supports passing cookies on redirects (added v0.92)\n\n\n## REQUIREMENTS:\n\nSnoopy requires PHP with PCRE (Perl Compatible Regular Expressions),\nand the OpenSSL extension for fetching HTTPS requests.\n\n## CLASS METHODS:\n\n### `fetch($uri)`\n\nThis is the method used for fetching the contents of a web page.\n`$uri` is the fully qualified URL of the page to fetch.\nThe results of the fetch are stored in $this-\u003eresults.\nIf you are fetching frames, then $this-\u003eresults\ncontains each frame fetched in an array.\n\n### `fetchtext($uri)`\n\nThis behaves exactly like `fetch()` except that it only returns\nthe text from the page, stripping out html tags and other\nirrelevant data.\n\n### `fetchform($uri)`\n\nThis behaves exactly like `fetch()` except that it only returns\nthe form elements from the page, stripping out html tags and other\nirrelevant data.\n\n### `fetchlinks($uri)`\n\nThis behaves exactly like `fetch()` except that it only returns\nthe links from the page. By default, relative links are\nconverted to their fully qualified URL form.\n\n### `submit($uri, $formVars)`\n\nThis submits a form to the specified `$uri`. `$formVars` is an\narray of the form variables to pass.\n\n### `submittext($uri, $formVars)`\n\nThis behaves exactly like `submit()` except that it only returns\nthe text from the page, stripping out html tags and other\nirrelevant data.\n\n### `submitlinks($uri)`\n\nThis behaves exactly like `submit()` except that it only returns\nthe links from the page. By default, relative links are\nconverted to their fully qualified URL form.\n\n\n## CLASS VARIABLES:    (default value in parenthesis)\n\n```txt\n$host             the host to connect to\n$port             the port to connect to\n$proxy_host       the proxy host to use, if any\n$proxy_port       the proxy port to use, if any\n                  proxy can only be used for http URLs, but not https\n$agent            the user agent to masqerade as (Snoopy v0.1)\n$referer          referer information to pass, if any\n$cookies          cookies to pass if any\n$rawheaders       other header info to pass, if any\n$maxredirs        maximum redirects to allow. 0=none allowed. (5)\n$offsiteok        whether or not to allow redirects off-site. (true)\n$expandlinks      whether or not to expand links to fully qualified URLs (true)\n$user             authentication username, if any\n$pass             authentication password, if any\n$accept           http accept types (image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*)\n$error            where errors are sent, if any\n$response_code    responde code returned from server\n$headers          headers returned from server\n$maxlength        max return data length\n$read_timeout     timeout on read operations (requires PHP 4 Beta 4+)\n                  set to 0 to disallow timeouts\n$timed_out        true if a read operation timed out (requires PHP 4 Beta 4+)\n$maxframes        number of frames we will follow\n$status           http status of fetch\n$temp_dir         temp directory that the webserver can write to. (/tmp)\n$curl_path        system path to cURL binary, set to false if none\n                  (this variable is ignored as of Snoopy v1.2.6)\n$cafile           name of a file with CA certificate(s)\n$capath           name of a correctly hashed directory with CA certificate(s)\n                  if either $cafile or $capath is set, SSL certificate\n                  verification is enabled\n```\n\n## EXAMPLES:\n\n### Example: fetch a web page and display the return headers and the contents of the page (html-escaped):\n\n```php\n$snoopy = new \\Purc\\Snoopy\\Snoopy();\n\n$snoopy-\u003euser = \"joe\";\n$snoopy-\u003epass = \"bloe\";\n\nif ($snoopy-\u003efetch(\"https://www.slashdot.org/\"))\n{\n    echo \"response code: \" . $snoopy-\u003eresponse_code . \"\u003cbr\u003e\\n\";\n    while (list($key, $val) = each($snoopy-\u003eheaders))\n    {\n        echo $key . \": \" . $val . \"\u003cbr\u003e\\n\";\n    }\n    echo \"\u003cp\u003e\\n\";\n\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults) . \"\u003c/pre\u003e\\n\";\n}\nelse\n{\n    echo \"error fetching document: \" . $snoopy-\u003eerror . \"\\n\";\n}\n```\n\n\n### Example:    submit a form and print out the result headers and html-escaped page:\n\n```php\n$snoopy = new \\Purc\\Snoopy\\Snoopy();\n\n$submit_url = \"https://lnk.ispi.net/texis/scripts/msearch/netsearch.html\";\n\n$submit_vars[\"q\"] = \"amiga\";\n$submit_vars[\"submit\"] = \"Search!\";\n$submit_vars[\"searchhost\"] = \"Altavista\";\n\nif ($snoopy-\u003esubmit($submit_url, $submit_vars))\n{\n    while (list($key, $val) = each($snoopy-\u003eheaders))\n    {\n        echo $key . \": \" . $val . \"\u003cbr\u003e\\n\";\n    }\n    echo \"\u003cp\u003e\\n\";\n\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults) . \"\u003c/pre\u003e\\n\";\n}\nelse\n{\n    echo \"error fetching document: \" . $snoopy-\u003eerror . \"\\n\";\n}\n```\n\n\n### Example:    showing functionality of all the variables:\n\n```php\n$snoopy = new \\Purc\\Snoopy\\Snoopy();\n\n$snoopy-\u003eproxy_host = \"my.proxy.host\";\n$snoopy-\u003eproxy_port = \"8080\";\n\n$snoopy-\u003eagent = \"(compatible; MSIE 4.01; MSN 2.5; AOL 4.0; Windows 98)\";\n$snoopy-\u003ereferer = \"https://www.microsnot.com/\";\n\n$snoopy-\u003ecookies[\"SessionID\"] = 238472834723489l;\n$snoopy-\u003ecookies[\"favoriteColor\"] = \"RED\";\n\n$snoopy-\u003erawheaders[\"Pragma\"] = \"no-cache\";\n\n$snoopy-\u003emaxredirs = 2;\n$snoopy-\u003eoffsiteok = false;\n$snoopy-\u003eexpandlinks = false;\n\n$snoopy-\u003euser = \"joe\";\n$snoopy-\u003epass = \"bloe\";\n\nif ($snoopy-\u003efetchtext(\"https://www.phpbuilder.com\"))\n{\n    while (list($key, $val) = each($snoopy-\u003eheaders))\n    {\n        echo $key . \": \" . $val . \"\u003cbr\u003e\\n\";\n    }\n    echo \"\u003cp\u003e\\n\";\n\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults) . \"\u003c/pre\u003e\\n\";\n}\nelse\n{\n    echo \"error fetching document: \" . $snoopy-\u003eerror . \"\\n\";\n}\n```\n\n\n### Example: fetched framed content and display the results\n\n```php\n$snoopy = new \\Purc\\Snoopy\\Snoopy();\n\n$snoopy-\u003emaxframes = 5;\n\nif ($snoopy-\u003efetch(\"https://www.ispi.net/\"))\n{\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults[0]) . \"\u003c/pre\u003e\\n\";\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults[1]) . \"\u003c/pre\u003e\\n\";\n    echo \"\u003cpre\u003e\" . htmlspecialchars($snoopy-\u003eresults[2]) . \"\u003c/pre\u003e\\n\";\n}\nelse\n{\n    echo \"error fetching document: \" . $snoopy-\u003eerror . \"\\n\";\n}\n```\n\n\n## COPYRIGHT:\n\nCopyright(c) 1999,2000 ispi. All rights reserved.\nThis software is released under the GNU General Public License.\nPlease read the disclaimer at the top of the Snoopy.class.php file.\n\n\n## THANKS:\n\nSpecial Thanks to:\n* Peter Sorger \u003csorgo@cool.sk\u003e help fixing a redirect bug\n* Andrei Zmievski \u003candrei@ispi.net\u003e implementing time out functionality\n* Patric Sandelin \u003cpatric@kajen.com\u003e help with fetchform debugging\n* Carmelo \u003ccarmelo@meltingsoft.com\u003e misc bug fixes with frames\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuratpurc%2FSnoopy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmuratpurc%2FSnoopy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmuratpurc%2FSnoopy/lists"}