0
我只想在登錄後從頁面中檢索源(字符串)。當我按登錄按鈕時,它給了我第一頁(登錄頁面)的來源。無論我輸入正確還是錯誤的密碼,結果都是一樣的。您的幫助將不勝感激。解析密碼保護的HTML
' - (IBAction爲)buttonPressed:(ID)發送{
// PERFORM LOGIN
url = [NSURL URLWithString:@"https://www.page asking username and password/"];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setRequestMethod:@"POST"];
[request setPostValue:userName.text forKey:@"UserID"];
[request setPostValue:password.text forKey:@"Password"];
[request setDelegate:self];
[request setDidFailSelector:@selector(PostFailed:)];
[request setDidFinishSelector:@selector(PostFinished:)];
[request startSynchronous];
}
- (void)PostFailed:(ASIHTTPRequest *)theRequest
{
//notify user
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Error sending request to the server" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
- (void)PostFinished:(ASIHTTPRequest *)theRequest
{
//這裏得到你的帖子的響應數據...
// ATTEMPT TO ACCESS ACCOUNT SUMMARY DATA
url = [NSURL URLWithString:@"https://www.page after I loged in"];
ASIHTTPRequest *mainRequest = [ASIHTTPRequest requestWithURL:url];
[theRequest setDelegate:self];
[mainRequest startAsynchronous];
NSLog(@"Response %d ==> %@", theRequest.responseStatusCode, [theRequest responseString]);
} `
我認爲,因爲我沒有實現提交按鈕,這也可能是我的原因。這是HTML閱讀提交按鈕的部分。我試圖實現它,但沒有運氣。你知道哪一個在setPostValue中,哪一個在forKey中? 謝謝! – Benjamen