Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4570026
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T19:18:12+00:00 2026-05-21T19:18:12+00:00

I making a web crawler and there are some pages that redirect to other.

  • 0

I making a web crawler and there are some pages that redirect to other. How I get the page that the original page redirected?

In some sites like xtema.com.br, I can get the url of redirection using the HttpURLConnection class with the getHeaderField(“Location”) method, but in others like visa.com.br, the redirection is made using javascript or another way and this method returns null.

There is some way to always get the page and the url resulting of redirection? The original page without the redirection is not important.

Thanks, and sorry for bad english.

EDIT: Using httpConn.setInstanceFollowRedirects(true) to follow the redirections and returning the URL with httpConn.getURL worked, but I have two issues.

1: The httpConn.getURL only will return the actual url of the redirected page if I call httpConn.getDate before. If I dont this, it will return the original URL before the redirections.

2: Some sites like visa.com.br get the answer 200, but if I open then in the web browser, I see another page.
Eg.: my program – visa.com.br – answer 200 (no redirections)
web broser – visa.com.br/go/principal.aspx – html code different of the version that i get in my program

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T19:18:13+00:00Added an answer on May 21, 2026 at 7:18 pm

    Use HttpURLConnection, it follows redirects by default.

    In case you want to see the redirected URL, you’ll have to do:

    httpConn.setInstanceFollowRedirects( false );
    httpConn.connect(); 
    int responseCode = httpConn.getResponseCode();
    while ((responseCode / 100) == 3) { /* codes 3XX are redirections */
       String newLocationHeader = httpConn.getHeaderField( "Location" );
       /* open a new connection and get the content for the URL newLocationHeader */
       /* ... */
       responseCode = httpConn.getResponseCode();
       /* do it until you get some code that is not a redirection */
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a web application that uses hash tags for page navigation like this
I'm making a web service that will only be used internally by other parts
I am making web page that will sequentially plays video from server on big
these day im making some web crawler script, but one of problem is my
I'm making a web-crawler. For finding the links in a page I was using
Im making a web page that has a 'fullscreen mode'. Its a normal web
i've been making web app's and working with various server side language like php,
hello I am making web page searching program with windows batch file before searching
Problem: I'm making a web service that allows developers to 'register' their Mongoose schemas
I'm making a web app. In it there are times when a form may

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.