I am trying to gather recent NFT transaction activity from an OpenSea profile. I am getting an error that states the program is unable to locate the element, however my element has been defined and I copy and pasted the element from the web page.
What I am trying to do is selecting the class that holds all of the activities on the section, and then using XPath to gather each items info and print the item info. After looking at guides, videos, and other peoples code, I am pretty lost on what I am doing wrong.
Any advice would be greatly appreciated.
Here is my code:
from selenium import webdriver
from selenium.webdriver.common.by import By
PATH = ('/Users/chris/Desktop/chromedriver')
driver = webdriver.Chrome(PATH)
driver.get("https://opensea.io/GaryVee?tab=activity")
action = driver.find_element(By.CLASS_NAME, 'Blockreact__Block-sc-1xf18x6-0 dBFmez')
for action in actions:
nft_name = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[2]/div/div/div/div[2]/span[1]/div/div/a').text
nft_id = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[2]/div/div/div/div[2]/span[2]/a/div').text
price_eth = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[3]/div/div[1]/div/div[2]/text()').text
price_usd = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[3]/div/div[2]/span/div/div').text
sending_user = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[5]/div/a/span').text
recieving_user = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div['
'2]/div[1]/button/div/div[6]/div/a/span').text
status = action.find_element(By.XPATH, './/*[@id="main"]/div/div/div[3]/div/div[3]/div[2]/div/div[2]/div['
'1]/button/div/div[1]/h6').text
print(nft_name, nft_id, price_eth, price_usd, sending_user, recieving_user, status)
Here is my error code:
/Users/chris/PycharmProjects/pythonProject/main.py:6: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
driver = webdriver.Chrome(PATH)
Traceback (most recent call last):
File "/Users/chris/PycharmProjects/pythonProject/main.py", line 11, in <module>
action = driver.find_element(By.CLASS_NAME, 'Blockreact__Block-sc-1xf18x6-0 dBFmez')
File "/Users/chris/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 1244, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "/Users/chris/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "/Users/chris/PycharmProjects/pythonProject/venv/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".Blockreact__Block-sc-1xf18x6-0 dBFmez"}
(Session info: chrome=127.0.0.1)
Stacktrace: