Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- async private void connectToLidlConnect()
- {
- string user = UserName;
- string pass = Password;
- ASCIIEncoding encoding = new ASCIIEncoding();
- string postData = "login=" + user + "&mdp=" + pass;
- byte[] data = encoding.GetBytes(postData);
- WebRequest request = WebRequest.Create("https://kundenkonto.lidl-connect.de/login.html");
- request.Method = "PUT";
- request.ContentType = "application/x-www-form-urlencoded";
- request.Headers["ContentLength"] = data.Length.ToString();
- using (Stream stream = await request.GetRequestStreamAsync())
- {
- stream.Write(data, 0, data.Length);
- }
- using (WebResponse response = await request.GetResponseAsync())
- {
- using (Stream stream = response.GetResponseStream())
- {
- using (StreamReader sr = new StreamReader(stream))
- {
- //
- var a = sr.ReadToEnd();
- }
- }
- }
- }
- async public Task LogIn()
- {
- CookieContainer container;
- var request = (HttpWebRequest)WebRequest.Create(LoginPageAdress);
- request.Method = "PUT";
- request.ContentType = "application/x-www-form-urlencoded";
- var buffer = Encoding.ASCII.GetBytes(loginData.ToString());
- request.Headers["ContentLength"] = buffer.Length.ToString();
- var requestStream = await request.GetRequestStreamAsync();
- requestStream.Write(buffer, 0, buffer.Length);
- container = request.CookieContainer = new CookieContainer();
- var request1 = (HttpWebRequest)WebRequest.Create(new Uri("https://kundenkonto.lidl-connect.de/mein-lidl-connect/mein-tarif/uebersicht.html"));
- request1.CookieContainer = container;
- var webResponse = await request1.GetResponseAsync();
- var response = (HttpWebResponse)webResponse;
- // Get the stream associated with the response.
- Stream receiveStream = response.GetResponseStream();
- // Pipes the stream to a higher level stream reader with the required encoding format.
- StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
- var html = readStream.ReadToEnd();
- CookieContainer = container;
- requestStream.Dispose();
- response.Dispose();
- readStream.Dispose();
- webResponse.Dispose();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement