[英]How would I go about writing a simple PHP bot?
我將如何編寫一個可以登錄並接收服務器發送的所有cookie的簡單PHP機器人? ...然后在需要時將其發送回去?
任何建議,將不勝感激。
如果由於某種原因不能在服務器上使用curl
擴展名(未安裝擴展名),則可以使用諸如Snoopy
類的類,該類仍將允許您使用curl
二進制文件或使用套接字來檢索信息。
史努比處理cookie。
至於編寫機器人本身,這只是發送適當請求的問題。 這是史努比的一個例子:
$snoopy = new Snoopy;
// The following needs to reflect the form configuration of the site
$login = array('usr' => 'hi', 'pwd' => 'hello');
if($snoopy->submit('http://example.com/login', $login) === false) {
// output the response code
die($snoopy->response_code . ':' . $snoopy->error);
}
//Request succeeded (doesn't mean we are logged in)
// output the results
echo $snoopy->results;
// Check the results to see if you are logged in and
// Continue using $snoopy.
// It will pass the proper cookies for the next requests.
借助cURL庫?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.