TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Lukasz Grygiel
NA
7
2.1k
Download The File After Logging IN
Jul 26 2013 5:51 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.ligatestowanba.ligspace.pl/index.php?pa=Admin&mod=Users&ac=Login
Logs:
Username: testtest
password: awdsa
Then, on a static link to the xml file that wants to download:
http://www.ligatestowanba.ligspace.pl/index.php?pa=Admin&mod=AdminCms&ac=ExportData&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. .....)
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();
Reply
Answers (
7
)
regex problem
what is the purpose of FOREACH