File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes [HELP] How to login to a website and get XML data of that site Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "[HELP] How to login to a website and get XML data of that site" Watch "[HELP] How to login to a website and get XML data of that site" New topic
Author

[HELP] How to login to a website and get XML data of that site

Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
Hello,

I'm trying to login to a website, named Maxithlon.com, to get xml data from that site. So I can make a program for the users. The only problem is, I can't get the connection.

This is the login string query: http://www.maxithlon.com/maxi-xml/login.php?user=Gynnad&scode=1q2w3e4r
Where Gynnad is the username and 1q2w3e4r is the securitycode.

First I thought it was a POST-method but it isn't, so this code isn't right, but is what i had:



and this was the result of that code:



Can someone help me with a explanation/tutorial or something?

Thanks!
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42624
    
  65
If the login works via GET, why are you trying to use POST? Do you have any indication that that should work?


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

The page apparently doesn't accept POST requests; it does accept GET requests. Just put the parameters in the URL:

Usually I'd suggest to not post read passwords, but in this case we wouldn't be able to test any solutions without it. I do suggest you to change it as soon as possible after finding a proper solution though.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
Rob Spoor wrote:The page apparently doesn't accept POST requests; it does accept GET requests. Just put the parameters in the URL:

Usually I'd suggest to not post read passwords, but in this case we wouldn't be able to test any solutions without it. I do suggest you to change it as soon as possible after finding a proper solution though.




Now it works to login, now i'm going to set some cookies so I can go to another website and get the content of that page. I will post that also here. If you have some comments please give them so I can learn about it!

The password is not the real password of the page, it is a securitycode and you can only access the pages with the xml, not the game.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39851
    
  28
Welcome to the Ranch

That question looks too difficult for us here on "beginning"; shall move it. Not sure whether to "servlets" in view of POST and GET, maybe I'll try "in general" and let Rob move it again if he thinks appropriate.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

Nah, it's good here. But you could also have considered Sockets and Internet Protocols
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49


Now I have this, with this output:


So I understand this page has 2 cookies, but witch one should I use and how can I go now to another webpage?
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49


Ok, with the second cookie the connection works! So now I will make the code a bit clearer and only use the 2th cookie. Someone has any tips for me?
Gynnad Paullussen
Ranch Hand

Joined: Jan 26, 2011
Posts: 49
How can I now see if the user is sign in? Because the website returns always a Cookie. So I can't check if the cookie is null.
 
Consider Paul's rocket mass heater.
 
subject: [HELP] How to login to a website and get XML data of that site