Welcome
I have the following problem, I want to automate the process of downloading the xml file of the site by the program but unfortunately I do not know what the problem is that it gets me to the page rather than the file ....
How do I do now:
Logs:
Username: testtest
password: awdsa
contents of the file should be this:
<? xml version = "1.0"?>
<teams/>
Unfortunately, the code that I wrote is not downloading this file, only that page service ....
Can anyone help me ..... HELP (F1. .....)
CODE
CookieContainer cookies = new CookieContainer();
//POST
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("http://www.ligatestowanba.ligspace.pl/index.php?pa=Admin&mod=Users&ac=Login");
request.Method = "POST";
request.CookieContainer = cookies;
string loginData = String.Format("username=testtest&password=awdsa");
request.ContentType = "application/x-www-form-urlencoded";
byte[] loginDataBytes = Encoding.ASCII.GetBytes(loginData);
Stream postData = request.GetRequestStream();
postData.Write(loginDataBytes, 0, loginDataBytes.Length);
postData.Close();
HttpWebResponse webResp = (HttpWebResponse)request.GetResponse();
StreamReader loResponseStream = new StreamReader(webResp.GetResponseStream());
string HelpResponse = loResponseStream.ReadToEnd();
//// Then grab the content of the desired page ////////////////////////
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.ligatestowanba.ligspace.pl/index.php?pa=Admin&mod=AdminCms&ac=ExportData&download=teams");
req.CookieContainer = cookies;
req.Method = "GET";
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
Stream resStream = res.GetResponseStream();
StreamReader reader = new StreamReader(resStream);
string input = reader.ReadToEnd();