简体   繁体   English

如何从随机文本框生成器复制+粘贴? 使用 python,webdriver selenium?

[英]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.根据我们现在掌握的信息,我想说您有两种选择来处理这个问题。

Option 1选项1

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()

Option 2选项 2

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.

相关问题 如何 select,使用 selenium webdriver (python) 复制和粘贴元素中的所有内容 - How to select, copy and paste everything within an element using selenium webdriver (python) 如何从 python selenium 中的只读框中复制文本 - How to copy the text from a readonly box in python selenium 复制 python 中的文本并在 webdriver 中按 Ctrl + V 粘贴 - Copy text in python and paste by Ctrl + V in webdriver 如何使用 Selenium WebDriver 和 Python 从表中获取元素(文本) - How to get element(text) from a table using Selenium WebDriver with Python 如何使用带有Python的Selenium Webdriver从工具提示中获取没有属性的文本? - How to get text from tooltip with no attributes using Selenium Webdriver with Python? 如何使用selenium webdriver python中的span中的定位器打印文本? - How to print the text using a locator from the span in selenium webdriver python? 粘贴页面中的所有文本 Selenium webdriver - Paste all text from a page Selenium webdriver 从环境变量复制文本并粘贴到 Selenium (Python) 中 - Copy text from environment variable and paste in Selenium (Python) Python:从记事本复制文本,然后粘贴到网页的特定框中? - Python: Copy text from notepad, then paste into a specific box in a webpage? 我想复制网页中的所有文本并将其粘贴到 word 文件中。 我正在使用 selenium 和 python - I want to copy all the text from a webpage and paste it to an word file. I am using selenium and python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM