我需要获取链接的最终 url。但是这个代码只给了我一个链接到它的商店
它返回给我链接:http://www.amazon.in/electronics/b?ie=UTF8&node=976419031
但我需要的是:http://www.amazon.in/Samsung-G-550FY-On5-Pro-Gold/dp/B01FM7GGFI?tag=prdeskdetailmob-21&ascsubtag=desktop-mobile-15920-blank-27092016
import mechanize
br = mechanize.Browser()
br.open("https://priceraja.com/r/go2store.php?mpc=mobile--1178916--15920--deskdetail")
br.select_form(nr=0)
br.submit()
x=br.geturl()
print x
最佳答案
from selenium import webdriver
chrome_path = r"C:\Users\Bhanwar\Desktop\price raja mobile\working\chromedriver.exe"
driver = webdriver.Chrome(chrome_path)
link = "https://priceraja.com/r/go2store.php?mpc=mobile--1185105--15236--deskdetail"
driver.get(link)
while(link == driver.current_url):
time.sleep(3)
redirected_url = driver.current_url
print redirected_url
关于python-2.7 - 需要获得确切的重定向链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39717941/