Selenium Web Scraping a cryptocurrency website by automating a click that copies a text

77 Views Asked by At

So I am trying to get a text from this website https://dexscreener.com/solana/7bzzop3qb2zk3r7wqrzjs5fpeeergdy3hgzxxrn97aey There is a button that when you click automatically copies the contact address of the cryptocurrency. I use selenium. Why? Because the website has cloudflare antidetection and after a long time I finally found code that can bypass it. So I need code that would be able to navigate to that page and click that button and print the pasted text. copy button

I only managed to write code for bypassing the cloudflare antibot detection, I tried using chatgpt to write me the code for getting the text but I keep getting errors. I am not that experienced with coding though.

Here is the code:

from time import sleep
from DrissionPage import ChromiumPage
p = ChromiumPage()
p.get('https://dexscreener.com/')

sleep(5)
1

There are 1 best solutions below

0
SpicyCatGames On

You need to click that button with selenium, then read the contents from clipboard. I assume you know how to click or were able to do it? Then your only challenge should be about how to read the clipboard contents?

import tkinter as tk
root = tk.Tk()
root.withdraw()
value = root.clipboard_get()

You can use this if the browser is running locally and you have only one instance running. Otherwise, you can try executing javascript that returns the clipboard value (haven't tried this myself).

try {
  return await navigator.clipboard.readText();
} catch (err) {
  return "";
}