我有这个代码,它的作用是生成一个随机的电子邮件与一个名单的名字。
但是,不是如何做到这一点,当chrome打开,在电子邮件部分输入生成的电子邮件。
这是密码
rom selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.support.ui import WebDriverWait
from config import keys
import threading
import time
import random
import string
import nameslist
"NAMES"
"From https://www.usna.edu/Users/cs/roche/courses/s15si335/proj1/files.php%3Ff=names.txt.html"
e_address_count = 1
email_providers = ["yahoo","gmail","hotmail","outlook"]
tlds = [".com",".es"] # You can add more domains
for i in range(e_address_count):
#random_numbers = random.randint(1,9999)
random_server_sel = "@"+random.choice(email_providers)+random.choice(tlds)
randnames = random.choice(nameslist.Names)
random_4lettercomb = ''.join(random.choice(string.ascii_letters) for l in range(2))
email = print(randnames+random_4lettercomb+random_server_sel)
time.sleep(0.5)
def timeme(method):
def wrapper(*args, **kw):
startTime = int(round(time.time() * 1000))
result = method(*args, **kw)
endTime = int(round(time.time() * 1000))
print((endTime - startTime)/1000, 's')
return result
return wrapper
# will cookies improve load time?
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
driver.get("https://www.fallablasgamez.com/votaci%C3%B3n-premi-flama")
@timeme
def order():
#intruducir email
time.sleep(0.3)
driver.find_element_by_xpath('//*[@id="input_comp-lgb8swdu"]').send_keys(email)
#intruducir numero falla Mayor
time.sleep(0.2)
driver.find_element_by_xpath('//*[@id="input_comp-lgb8qa87"]').send_keys(keys['numeromañor'])
#Introducir falla Menor
time.sleep(0.2)
driver.find_element_by_xpath('//*[@id="login-form"]/div[5]/div/div/input').send_keys(keys['numeromenor'])
#Botton Capcha
#Botton Enviar
driver.find_element_by_xpath('/html/body/div[1]/div/div[3]/div/main/div/div/div/div[2]/div/div/div/section[2]/div[2]/div/div[1]/div/div/form/div/div/div[6]/button/span').click()
if __name__ == '__main__':
# get product url
driver.get(keys['product_url'])
order()
复制生成的电子邮件并将其插入到显示电子邮件的位置这将打印生成的电子邮件的代码
email = print(randnames+random_4lettercomb+random_server_sel)
我在这个区域输入它,这样它就可以被附加
driver.find_element_by_xpath('//*[@id="input_comp-lgb8swdu"]').send_keys(email)
1条答案
按热度按时间bn31dyow1#
由于缺少所需的
config
和namelist
模块,因此无法立即复制代码。值得注意的是,使用print
不会返回任何可以存储在变量中的值。因此,如果您使用print
创建一个值,并尝试使用赋值语句将其存储在变量中,则该变量将被赋值为None
。如果你想把连接的字符串赋给
email
变量,你可以像这样使用字符串连接: