I am trying to make a silent login to web site to check status of restaurant, I made it with ChromeDriver, it works okay but as it needs to open a popup windows each time connecting and checking the status its blocking working on pc. I am trying to make a silent login, I write the following code, but I got 405 Error where I can't find any fix for it, I search a lot but all the information is on server side, where I don't have any control at all.. my code is:
string WebServiceURL = "https://siparistakip.yemeksepeti.com/login.html"; // store Url Of service in string
string formParams = string.Format("userName={0}&password={1}&remember={2}", username, passwd, true);
// Convert our JSON in into bytes using ascii encoding
ASCIIEncoding encoding = new ASCIIEncoding();
byte[] data = encoding.GetBytes(formParams);
// HttpWebRequest
HttpWebRequest webrequest = (HttpWebRequest)WebRequest.Create(WebServiceURL);
webrequest.Method = "POST";
webrequest.ContentType = "application/x-www-form-urlencoded";
webrequest.ContentLength = data.Length;
// Get stream data out of webrequest object
Stream newStream = webrequest.GetRequestStream();
newStream.Write(data, 0, data.Length);
newStream.Close();
// Declare & read the response from service
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
// Fetch the response from the POST web service
Encoding enc = System.Text.Encoding.GetEncoding("utf-8");
StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc);
string result = loResponseStream.ReadToEnd();
loResponseStream.Close();
webresponse.Close();
MessageBox.Show(result);
Any hint where I make mistake ? or its not possible to do this on this website ? Thanks a lot
Aucun commentaire:
Enregistrer un commentaire