Unable to locate a particular element in selenium python -
website url using selenium-python not able locate particular element in website. looking webscrape info { data- coordinates } it. couldn't locate element , take info it. please kindly share thoughts on issue here. screenshot of html code , element. in advance
tried code : -
fill=driver.find_element_by_xpath("//div[contains(@class,'inner fill')]") latlong=fill.find_element_by_xpath("//div[contains(@class,'map.space-map.leaflet-container')]") latlong.find_attribute["data-coordinates"] result :- message: unable locate element: {"method":"xpath","selector":"//div[contains(@class,'map.space-map.leaflet-container')]"}
if can add 2 cents:
you can of selenium + beautifulsoup(https://www.crummy.com/software/beautifulsoup/bs4/doc/) (do : pip install beautifulsoup)than run below code:
from selenium import webdriver bs4 import beautifulsoup driver = webdriver.chrome() url= "https://www.appearhere.co.uk/spaces/north-kensington-upcycling-store-and-cafe" driver.maximize_window() driver.get(url) content = driver.page_source.encode('utf-8').strip() soup = beautifulsoup(content,"html.parser") cord = soup.find("div", {"class": "map space-map leaflet-container leaflet-fade-anim"})['data-coordinates'] print cord driver.quit()
it print coordinates as:
[51.5235108631773, -0.206594467163086]
hope want only.enjoy
Comments
Post a Comment