Python (pyautogui / Selenium) save selected text

Asked

Viewed 990 times

-1

Good afternoon!

I’m having a doubt here and I’d really like some help:

I’m doing some tests here in python, automating the login to instagram, accessing the followers page and selecting the names (the same way I would manually, but using pyautogui’s dragTo) and after that I press Control + C to copy the selected field. up to that point, it’s all working super well, my doubt is:

how to get the text I gave control + C to store in a variable? is it possible? if not, there is some alternative way to do this?

follows the function I’ve done so far:

inserir a descrição da imagem aqui

1 answer

1


There are many ways to get the content copied in Python, one of them being the package pyperclip. This package has two very interesting functions that are the copy() to copy a text and the paste() to glue.

Use the function paste to get the content copied and put the return in a variable, thus:

import pyperclip
text = pyperclip.paste() 

Browser other questions tagged

You are not signed in. Login or sign up in order to post.