i want read content of text file located in site
https://www.frbservices.org/epaymentsdirectory/fedachdir.txt
i want read using java . started using httpsurlconnection class .
when take above url in browser , first redirect agreement page , if click agree button , can see text file . how can same procedure using httpsurlconnection class ?
this tried:
url url = new url("https://www.frbservices.org/epaymentsdirectory/submitagreement?agreementvalue=agree"); httpsurlconnection https = (httpsurlconnection) url.openconnection(); https.setrequestmethod("post"); https.connect(); url = new url("https://www.frbservices.org/epaymentsdirectory/fedachdir.txt"); httpsurlconnection http = (httpsurlconnection) url.openconnection(); http.setrequestmethod("get"); http.connect(); string line = ""; bufferedreader in = new bufferedreader( new inputstreamreader(http.getinputstream())); while( (line = in.readline()) != null ) {system.out.println(line); //process line logger.debug(line); processline(line); } http.disconnect();
any inputs highly appreciable
looks post request accept agreement results in session cookie server stores whether or not agreement accepted. try getting jsessionid cookie "set-cookie" header , sending in "cookie" header simulate behaviour of browser.
Comments
Post a Comment