[英]How to copy + paste from a random text box generator? Using python, webdriver selenium?
I am trying to copy + paste an random email generator that is generating from a text box?我正在尝试复制 + 粘贴从文本框生成的随机 email 生成器? I just can't get it to copy or paste it!
我就是无法复制或粘贴它! Anyone got any idea?
有人知道吗?
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import random
elementlist = []
while True:
driver = webdriver.Chrome('/usr/lib/chromium-browser/chromedriver')
#Get email
driver.get('https://temp-mail.org/en/');
time.sleep(5)
element = driver.find_element_by_id('mail')
time.sleep(5)
With the information we have right now, I would say you have 2 options to handle the issue.根据我们现在掌握的信息,我想说您有两种选择来处理这个问题。
Get the text from the email box and save it in a variable.从 email 框中获取文本并将其保存在变量中。
element = driver.find_element_by_id('mail')
emailtextvalue = element.text
And use the "emailtextvalue" variable value for pasting to somewhere else.并使用“emailtextvalue”变量值粘贴到其他地方。
import pyperclip
...
element = driver.find_element_by_id('mail')
emailtextvalue = element.text
pyperclip.copy(emailtextvalue)
...
pyperclip.paste()
Click on the actual copy button and use the clipboard value.单击实际复制按钮并使用剪贴板值。
import pyperclip
...
element = driver.find_element_by_xpath("//button[@data-clipboard-action='copy']")
emailtextvalue = element.click
...
pyperclip.paste()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.