0

When you go to the site, https://www.jimmyjazz.com/search?keywords=11468285, you are redirected to https://www.jimmyjazz.com/mens/footwear/adidas-solar-hu-nmd/BB9528.

I would like to use requests to enter that search link, then return the url that it is redirected to.

Here is my code to do that:

import requests
from bs4 import BeautifulSoup
sitename = "https://www.jimmyjazz.com/search?keywords=11468285"
response = requests.get(sitename, allow_redirects=True)
print(response.url)

But it still returns the original url:

PS C:\Users\jokzc\Desktop\python\learning requests> py test2.py
https://www.jimmyjazz.com/search?keywords=11468285

How would I append my code to make fix that? Thanks :)

TTV jokzyz
  • 349
  • 1
  • 3
  • 13

1 Answers1

0

This doesn't actually send a 302 redirect code back. I did the same HTTP GET call in postman, and it appears that it returns a 200 OK response:

enter image description here

Same goes for chrome dev tools, looking at the network traffic: enter image description here

I think that somewhere in their JavaScript code they are setting the location.href to be a new url. I didn't go through the whole JS stack trace to prove it, but that is my best guess.

Jon
  • 1,820
  • 2
  • 19
  • 43