Snoopy類是一個用于HTTP請求和抓取網頁內容的PHP庫。以下是Snoopy類的一些常見用法:
include_once('Snoopy.class.php');
$snoopy = new Snoopy;
$snoopy->fetch('http://example.com');
$result = $snoopy->results;
echo $result;
include_once('Snoopy.class.php');
$snoopy = new Snoopy;
$snoopy->submit('http://example.com', array('username' => 'admin', 'password' => 'password'));
$result = $snoopy->results;
echo $result;
include_once('Snoopy.class.php');
$snoopy = new Snoopy;
$snoopy->agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3';
$snoopy->referer = 'http://example.com';
$snoopy->fetch('http://example.com');
$result = $snoopy->results;
echo $result;
include_once('Snoopy.class.php');
$snoopy = new Snoopy;
$snoopy->cookies['PHPSESSID'] = '1234567890abcdef';
$snoopy->fetch('http://example.com');
$result = $snoopy->results;
echo $result;
include_once('Snoopy.class.php');
$snoopy = new Snoopy;
$snoopy->fetch('http://example.com/image.jpg');
$snoopy->saveToFile('local/path/image.jpg');
這些只是Snoopy類的一些基本用法示例,實際上它還有許多更高級和豐富的功能,如處理重定向、處理表單、處理AJAX請求等。您可以參考Snoopy類的文檔了解更多用法和功能。