Jul-01-2020, 01:09 PM
(Jul-01-2020, 10:06 AM)Larz60+ Wrote: example:
from selenium import webdriver from selenium.webdriver.common.by import By ... browser.find_element(By.XPATH, '/html/body/div[1]/div[2]/div[1]/div/svg/g[6]/image[133]')you can get xpath by using your browsers 'copy' in 'inspect element'
if firefox:
- with page you wish to scrape in browser, place cursor over item you want XPath for
- right click and select 'Inspect Element'
- Place cursor over highlighted code
- Right click, select copy
- select XPath
- Paste into code
I know about how to extract data using selenium and xpath, but I want to define a function that does the job for me as I input the xpath of the element. Thank you so much for your reply.