Skip to content Skip to sidebar Skip to footer

Get Url In Selenium Python

I am very new to python and I am looking to scrape following website:Link I think that Selenium might be the right tool and I started to write following code: from selenium import

Solution 1:

Did you made any other request in between checking your script returned URL and the URL shown by the browser. The request URL sent post the Keys.RETURN adds a session identifier with the URL, which might be the reason why you are getting different URL.

I have this script

from selenium import webdriver
from selenium.webdriver.common.keysimportKeys
chromepath='chrome_driver_path'//change this to your chromedriver path
driver = webdriver.Chrome(chromepath)

driver.get('http://planning.hackney.gov.uk/Northgate/PlanningExplorer/generalsearch.aspx')

print(driver.current_url)

elem = driver.find_element_by_id('txtPostCode')
elem.clear()
elem.send_keys("E9 7JP")
elem.send_keys(Keys.RETURN)

print (driver.current_url)

driver.quit()

Keypress code has been copied from your code itself. I get an identical URL from both the browser and the script

Script gives me this URL - Link Browser gives me this same URL - Copied Manually

Post a Comment for "Get Url In Selenium Python"