You can simulate a HTTP session from the browser from any scripting language. You should login by POSTing a
{'action':'login','params':{'username':"a",'password':"a", 'locale':'en_US'}}
to <myhost>/xas/
That should return a 200 -ok http status code along with a set-cookie HTTP header. You can use that cookie to post subsequent requests on the runtime, such as a filerequest.
I think you could better use web services instead of simulating the client. FTP might also be a good option.
But it may depend on what kind of application this functionality must be implemented in.
To establish a session if you know the username and password, you need to POST data to <apphost>/xas in the following format:
{"action":"login","params":{"username":"USERNAME","password":"PASSWORD","locale":""}}
The response to this request will contain two cookies: XASSESSIONID and XASID. Those two cookies need to be added to any subsequent request to the xas / file servlet. How this is done depends entirely on the environment you are working on.
In general, try Google 'YOURLANGUAGE post http data to url' and 'YOURLANGUAGE set/get cookie headers' :)
Note: this is no official api, so it might change in future versions.
I think you could better use web services instead of simulating the client. FTP might also be a good option.
But it may depend on what kind of application this functionality must be implemented in.