Python 通过Selenium访问重定向URL

Python 通过Selenium访问重定向URL,python,python-2.7,redirect,selenium,Python,Python 2.7,Redirect,Selenium,以下是我目前的代码: from selenium import webdriver driver = webdriver.Chrome() driver.get("https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code") p

以下是我目前的代码:

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code")
print driver.current_url

即使浏览器在使用
driver.get()
加载URL后重定向到不同的URL,当我打印
print driver.current\u URL
时,当然,打印的URL是原始URL,而不是重定向。有没有办法让Selenium在它打开的浏览器中“查看”实际的当前URL

你看过你正在使用的网址了吗?它包含重定向?@TehTris当前URL重定向到另一个URL,URL末尾带有访问代码字符串。我想自动获取的代码(而不是每次从浏览器复制)类似于
redirect\u uri=driver.current\u url.split('redirect\u uri%3D')[-1]
您在寻找什么?这会将“http%3A//pythondev.insta.com/instagramredirect.html%26response\u type%3Dcode”放入一个字符串
redirect\u uri
I需要重定向URL
https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code
创建。粘贴
https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code
进入浏览器。您是否查看了正在使用的URL?它包含重定向?@TehTris当前URL重定向到另一个URL,URL末尾带有访问代码字符串。我想自动获取的代码(而不是每次从浏览器复制)类似于
redirect\u uri=driver.current\u url.split('redirect\u uri%3D')[-1]
您在寻找什么?这会将“http%3A//pythondev.insta.com/instagramredirect.html%26response\u type%3Dcode”放入一个字符串
redirect\u uri
I需要重定向URL
https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code
创建。粘贴
https://api.instagram.com/oauth/authorize/?client_id=cb009a1b2b4601317355f&redirect_uri=http://pythondev.insta.com/instagramredirect.html&response_type=code
输入您的浏览器。