Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Requests and redirections, waste of time? [closed] without wasting too much if your time.
The question is published on by Tutorial Guruji team.
The question is published on by Tutorial Guruji team.
Let’s say that I perform a GET request on a URL (this one for example: http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398), and that I trace the request:
response = requests.get(url, timeout=10) if response.history: print("Request was redirected") for resp in response.history: print("Status code, URL: {}, {}".format(resp.status_code, resp.url)) print("Final destination:") print("Status code, URL: {}, {}".format(resp.status_code, response.url)) else: print("Request was not redirected")
The output is:
Request was redirected Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398 Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398?cookieSet=1 Final destination: Status code, URL: 302, http://pubs.acs.org/doi/abs/10.1021/acs.accounts.5b00398
I would like to know a few things:
- why does the server redirects me to the url + cookieSet=1 ? To give me a cookie ?
- Does this redirection take time ?
- If so, could I request the cookie page in the first place ?
- If I have to perform several requests on the same server, should I use a session, if the server gives me a cookie ?
Answer
- why does the server redirects me to the url + cookieSet=1 ? To give me a cookie ?
Ask the web site programmer.
- Does this redirection take time ?
Sure, every request takes some time.
- If so, could I request the cookie page in the first place ?
Yes, you can.
- If I have to perform several requests on the same server, should I use a session, if the server gives me a cookie ?
Probably a session would reduce the redirects
We are here to answer your question about Requests and redirections, waste of time? [closed] - If you find the proper solution, please don't forgot to share this with your team members.