url input stream returning blank
hi all,
i'm trying to extract a particular website into a html text file but i've tried many ways and so far i'm getting a blank website. i can open the website normally on a browser and its source code is viewable within the browser, but when i do a inputstream on it, i get nothing but nulls.
it's basically a linkbee redirection website e.g. http:// linkbee.com/FTHNN. i realize it's a redirection website but i should still be able to extract the html code of this website. the redirection occurs only after clicking a button, there's no timer, and i don't require actually following the redirection, i simply need to the url that it redirects to. in this case it can be found in line 81 input type='hidden' id='urlholder' value='http://www.megaupload.com/?d=VBS1H7ZK'.
my source code is -
Code :
URL u = new URL(str);
URLConnection uconn = u.openConnection();
uconn.connect();
InputStream is = uconn.getInputStream();
br3 = new BufferedReader(new InputStreamReader(is));
while(true) br3.readLine();
it works for every website i've tried on but this.
thanks for any help
Re: url input stream returning blank
Quote:
it works for every website i've tried on but this.
Which website is "this"??
What do you read from that website?
When i tried reading from http:// linkbee.com/FTHNN (space after //) I get 1 byte of 0xFF.
Re: url input stream returning blank
Quote:
Originally Posted by
Norm
Which website is "this"??
What do you read from that website?
When i tried reading from http:// linkbee.com/FTHNN (space after //) I get 1 byte of 0xFF.
i'm sorry, 'this' website is http:// linkbee.com/FTHNN without the space after //. I can't type the full url because it turns into a hyperlink like this Linkbee redirection, please wait...
Re: url input stream returning blank
Are you after the HTML of the redirect site, or the HTML of the site you are redirected to?
Re: url input stream returning blank
Sometimes websites require a user agent or it will return unexpected results. Try setting it with something like the following
Code :
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 4.01; Windows NT)");
There is usually a reason for a server to be configured in such a way. As a result I'd recommend checking to be sure you are not violating any policies in doing so.
Re: url input stream returning blank
Quote:
Originally Posted by Freaky Chris
Are you after the HTML of the redirect site, or the HTML of the site you are redirected to?
i'm after the HTML of the site i am redirected to
Quote:
Originally Posted by copeg
There is usually a reason for a server to be configured in such a way. As a result I'd recommend checking to be sure you are not violating any policies in doing so.
hmm true, i should figure that out first, thanks.
Re: url input stream returning blank
Btw, the default User-Agent when using Java URL.openConnection() is Java/version
Oh and setting the user agent as suggested by copeg works just dandy for the above mentioned url.
// Json
Re: url input stream returning blank
Quote:
Originally Posted by
Json
Btw, the default User-Agent when using Java URL.openConnection() is Java/version
Oh and setting the user agent as suggested by copeg works just dandy for the above mentioned url.
// Json
interesting, this explains everything! thank you very much