1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
CookieContainer cookieContainer = new CookieContainer();
/*
* Envoie d'une requete de login et récupération du cookie
*/
HttpWebRequest req_Login = (HttpWebRequest)HttpWebRequest.Create(URL_Login);
req_Login.CookieContainer = cookieContainer;
req_Login.Method = "POST";
req_Login.ContentType = "application/x-www-form-urlencoded";
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes("...");
req_Login.ContentLength = data.Length;
Stream stream = req_Login.GetRequestStream();
stream.Write(data, 0, data.Length);
stream.Close();
HttpWebResponse rep_Login = (HttpWebResponse)req_Login.GetResponse();
//rep_Login.Close();
/*
* Accès à la page demandée
*/
string URL = UrlDomaine + ".../my_votes.asp";
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(URL);
req.CookieContainer = cookieContainer;
req.Method = "GET";
HttpWebResponse rep = (HttpWebResponse)req.GetResponse();
ProcessStartInfo sInfo = new ProcessStartInfo(rep.ResponseUri.ToString());
Process.Start(sInfo); |
Partager