html 페이지를 구문 분석하고 싶습니다. 그러나 나는 서버에서 인증 할 때만이 html 페이지를 읽을 수 있습니다. 하지만 내 현재 코드로, 내가 로그인하고 있지 않다의이 와서 여기에 내 현재 코드입니다.WP8에서 CookieContainer 사용
// This functions start when I click a button
private void BtLog_Click(object sender, RoutedEventArgs e)
{
string url = "https://subcard.subway.co.uk/de_cardholder/servlet/SPLoginServlet";
StringBuilder body = new StringBuilder();
body.Append("language=" + "de");
body.Append("&user=" + tbUser.text);
body.Append("&password=" + pbPassword.Password);
body.Append("&transIdentType=" + "1");
body.Append("&programID=" + "6");
bool isNetwork = NetworkInterface.GetIsNetworkAvailable();
if (!isNetwork)
{
}
else
{
try
{
WebClient webClient = new WebClient();
webClient.Headers["Content-Type"] = "application/x-www-form-urlencoded"; // Your Application Header Content-Type
webClient.Encoding = Encoding.UTF8;
webClient.UploadStringAsync(new Uri(url), "POST", body.ToString(), null);
WebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
client.DownloadStringAsync(new Uri("https://subcard.subway.co.uk/de_cardholder/JSP/SPSummary.jsp"));
}
catch
{
MessageBox.Show("Error");
}
}
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
MessageBox.Show(e.Result.ToString());
// If the I am logged in and got the string I want to parse it, but first the other thing have to work
}
은 내가 cookiecontainer와 함께 일해야 생각했지만, 이것이 어떻게 작동하는지 모르겠어요. 내 문제에 대한 조언이나 해결책을 가져 주셔서 감사합니다 !!
가능한 복제본 [WebClient에서 쿠키를 어떻게 가져올 수 있습니까?] (http://stackoverflow.com/questions/2825377/how-can-i-get-the-webclient-to-use-cookies) – bdimag
그게 작동 할 수 있지만 WP8에 대한 GetWebRequest 사용할 수 없습니다 : ( – user3493797