i'm trying download links site: http://prices.shufersal.co.il
when try download myself site it's work fine, when i'm trying download link code, it's saying filenotfoundexception - 404 status code.
here link for example: http://pricesprodpublic.blob.core.windows.net/price/price7290027600007-001-201601290030.gz?sv=2014-02-14&sr=b&sig=1ksetqgvmsbwgnqq6ngpgcqfsx4r%2blusvcmf%2f1ppj8q%3d&se=2016-01-28t23%3a24%3a43z&sp=r
i think each time requesting page it's giving different download links, still can not download code.
this code:
public void download() { (int currtype = 1; currtype <= shufersalconstants.types.size(); currtype++) { string link = base_url + cat_modifier + currtype + modifier_seperator + store_modifier + 0; stringbuilder = httputils.sendgetrequest(link); system.out.println(a.tostring()); fetchlinks(a.tostring()); } } @override public arraylist<string> fetchlinks(string htmlpage) { logger.log("fetching links html page"); // creating new list hold links .gz files arraylist<string> links = new arraylist<string>(); // getting start position of first download link int startlinkpos = htmlpage.indexof("http://pricesprodpublic.blob.core.windows.net"); // getting end position of first download link int endlinkpos = htmlpage.indexof(" target=", startlinkpos); // running on string until there no more download links while (startlinkpos != -1) { links.add(htmlpage.substring(startlinkpos, endlinkpos - 1)); httputils.getgzstream(htmlpage.substring(startlinkpos, endlinkpos - 1)); // returning list of links return (links); }
the httputils class doing regular request url.
this method in httputils class:
/** * function gets gz file link function gets * @param link link gz file * @return gzstream use */ public static gzipinputstream getgzstream(string link) { httpurlconnection connection = null; gzipinputstream gzstream = null; try { // create connection using link parameter url url = new url(link); connection = (httpurlconnection) url.openconnection(); // response connection after sending request inputstream = (inputstream) connection.getinputstream(); // creating gz stream base on inputstream gzstream = new gzipinputstream(is); } catch (exception e) { logger.logerror("an error occured while trying gz stream"); e.printstacktrace(); } // returning response return (gzstream); }
can me writing such thing? i'm stuck , need download files..
thanks.
Comments
Post a Comment