0 Replies - 207 Views - Last Post: 26 July 2013 - 02:46 AM Rate Topic: -----

#1 wyczes  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-July 13

Download the file after logging IN

Posted 26 July 2013 - 02:46 AM

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:
I go to the website: http://www.ligatesto...=Users&ac=Login

Logs:
Username: testtest
password: awdsa

Then, on a static link to the xml file that wants to download: http://www.ligatesto...&download=teams

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. .....)

 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();




Is This A Good Question/Topic? 0
  • +

Page 1 of 1