You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by gdrsantosh <gd...@gmail.com> on 2015/02/10 13:35:43 UTC
Handling Url's redirection using Httpclient
I am using Httpclient to get the web page content,when we specify below urls
like
http://www.milwaukeetool.com/power-tools#product+Types=Diamond+Coring
it will be redirected to
http://www.milwaukeetool.com/power-tools?product+Types=Diamond+Coring
and
http://blackwoods.com.au/browse/flat-cut-off-wheels-metal-flexovit/302022874
it will be redirected to
http://blackwoods.com.au/search/flat-cut-off-wheels-metal-flexovit/302022874
and giving invalid page content.
So, I am looking for a solution to handle rediection to get correct page
content using HttpClient.
Below is the code which I am using to handle redirection using httpclient..
HttpGet httpGet = new HttpGet(UrlRequest);
httpclient = HttpClientBuilder.create().setRedirectStrategy(new
LaxRedirectStrategy()).build();
HttpResponse response = httpclient.execute(httpGet);
HttpEntity entity = response.getEntity();
thirdPartyPageContent=EntityUtils.toString(entity);
--
View this message in context: http://httpcomponents.10934.n7.nabble.com/Handling-Url-s-redirection-using-Httpclient-tp25485.html
Sent from the HttpClient-User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Handling Url's redirection using Httpclient
Posted by "Bhowmik, Bindul" <bi...@gmail.com>.
Hello,
On Tue, Feb 10, 2015 at 5:35 AM, gdrsantosh <gd...@gmail.com> wrote:
> I am using Httpclient to get the web page content,when we specify below urls
> like
>
> http://www.milwaukeetool.com/power-tools#product+Types=Diamond+Coring
> it will be redirected to
> http://www.milwaukeetool.com/power-tools?product+Types=Diamond+Coring
Looking at the sites, they are using Javascript (document.location) to
redirect, rather than HTTP 3xx status codes. So, this is outside the
scope of HTTP Client. You will have to parse/process the HTML body and
Javascript to achieve that redirect.
Regards,
Bindul
>
> and
>
> http://blackwoods.com.au/browse/flat-cut-off-wheels-metal-flexovit/302022874
> it will be redirected to
> http://blackwoods.com.au/search/flat-cut-off-wheels-metal-flexovit/302022874
>
> and giving invalid page content.
>
> So, I am looking for a solution to handle rediection to get correct page
> content using HttpClient.
> Below is the code which I am using to handle redirection using httpclient..
>
> HttpGet httpGet = new HttpGet(UrlRequest);
> httpclient = HttpClientBuilder.create().setRedirectStrategy(new
> LaxRedirectStrategy()).build();
> HttpResponse response = httpclient.execute(httpGet);
> HttpEntity entity = response.getEntity();
> thirdPartyPageContent=EntityUtils.toString(entity);
>
>
>
>
> --
> View this message in context: http://httpcomponents.10934.n7.nabble.com/Handling-Url-s-redirection-using-Httpclient-tp25485.html
> Sent from the HttpClient-User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org