Python Forum
python how to check short url working?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python how to check short url working?
#3
(Mar-16-2020, 05:02 PM)buran Wrote: the last url in response.history is the same as response.url after all redirects:
import requests
url = 'http://jd.cn.hn/aeXb'
response = requests.get(url)
print([resp.url for resp in response.history])
print(response.url)
Output:
['http://jd.cn.hn/aeXb', 'https://www.weibo.com/', 'http://weibo.com/overseas'] https://www.weibo.com/overseas
if I run your code, I get the same:
Output:
301 http://jd.cn.hn/aeXb 302 https://www.weibo.com/ 301 http://weibo.com/overseas https://www.weibo.com/overseas
I see just one difference between response.history and response.url - the schema http vs https

thanks for reply. that's why i ask here. i think we get link with wrong way. here is how it work in browser
imgur.com/a/2EyQDyK
Reply


Messages In This Thread
python how to check short url working? - by Pyguys - Mar-16-2020, 04:49 PM
RE: python how to check short url working? - by Pyguys - Mar-16-2020, 11:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Short link URL Evil_Patrick 5 3,194 Jul-10-2020, 10:14 AM
Last Post: steve_shambles
  Simple Element Check Code in Selenium Not Working digitalmatic7 1 3,051 Feb-18-2018, 06:53 AM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020