我正在嘗試使用以下cURL操作登錄bangme.net圖片評級網站。當我檢查登錄表單時,這些ID是signin_UserName,signin_UserPass。名稱是簽名$用戶名,簽署$ UserPass。該腳本似乎沒有與下劃線一起工作,因爲結果導致我要求我登錄儘可能遠的頁面。我無法使用美元符號名稱,因爲它把它變成了一個變量。我注意到這個和類似腳本的一些示例顯示了一些以'&'標誌開頭的字段,當它們沒有在他們想要登錄的網頁的表單上。這是做什麼的?任何你可以提供的援助將不勝感激。謝謝。使用捲曲登錄
$username = "username";
$password = "password";
$url = "http://www.bangme.net/starform.aspx";
$cookie = "cookie.txt";
$postdata = "signin_UserName=" .$username . "signin_UserPass=" .$password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
新代碼:
$username = "username";
$password = "password";
$url = "http://www.bangme.net/signin.aspx";
$cookie = "cookie.txt";
$post = array(
'__EVENTTARGET'=>"" ,
'__EVENTARGUMENT'=>"",
'__VIEWSTATE'=>"/wEPDwUJMzQ0MjU1MjA0ZBgBBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAwUJbGFzdHBob3RvBQh2b3RleWVzMgUHdm90ZW5vMgfkai25gOMuDdbmzYMWHA2LgYKt",
'__EVENTVALIDATION'=>"/wEWDgLmnpGMBwKOwMbqCwK4wb4IAv/10agEAqHH7a8KAtXfk+ULAt/Q94gCAvS2udYOAqrdhtcHAq+k5d0LAo+Au5MKApm/3+0OAqDCuuYMArCmgTeosqrEgmB3P5bavC40rTc6dbeF1g==",
'signin$UserName'=>$username ,
'signin$UserPass'=>$password ,
'signin$Button1.x'=>42,
'signin$Button1.y'=>17
);
$postData = http_build_query($post);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);//changed from 0 to 1
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt($ch, CURLOPT_REFERER, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);//new
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);//new
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
謝謝巴巴,你能告訴我如何實現你在C中描述的參數嗎? – KiloJKilo 2012-04-03 00:47:03
以及您如何確定這些參數是必需的? – KiloJKilo 2012-04-03 00:54:39
這就是當你點擊提交 – Baba 2012-04-03 00:56:22