注册临时邮箱
2019-03-29 本文已影响0人
戒灵
python+requests+selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
import json
import re
import requests
from lxml import etree
def selum_chrome():
session = requests.Session()
r = session.get('https://www.linshiyouxiang.net/')
r = session.get('https://www.linshiyouxiang.net/api/v1/mailbox/keepalive')
mailbox_str =json.loads(r.text)
mailbox = mailbox_str['mailbox']
email_address_net = mailbox+'@linshiyouxiang.net'
print(mailbox)
driver = webdriver.Chrome("./chromedriver.exe")
driver.maximize_window()
driver.get(
'https://www.amazon.com/ap/signin?openid.return_to=https%3A%2F%2Fwww.amazon.com%2F%3Fref_%3Dnav_ya_signin&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.assoc_handle=usflex&openid.mode=checkid_setup&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0')
driver.find_element_by_id('createAccountSubmit').click()
time.sleep(5)
driver.find_element_by_id('ap_customer_name').send_keys(email_address_net)
time.sleep(1)
driver.find_element_by_id('ap_email').send_keys(email_address_net)
time.sleep(1)
driver.find_element_by_id('ap_password').send_keys(email_address_net)
time.sleep(1)
driver.find_element_by_id('ap_password_check').send_keys(email_address_net)
time.sleep(1)
driver.find_element_by_id('continue').click()
time.sleep(5)
capch_url = driver.current_url
# 出现注册验证码(手动输入)
if capch_url == 'https://www.amazon.com/ap/register':
driver.find_element_by_id('ap_password').send_keys(email_address_net)
driver.find_element_by_id('ap_password_check').send_keys(email_address_net)
print('Thread Communicate:data:''请20秒内手动输入验证码...')
time.sleep(20)
driver.find_element_by_id('continue').click()
# # 发送...等待区邮件验证码
print('Thread Communicate:data:''等待接收邮箱验证码...')
r=session.get("https://www.linshiyouxiang.net/api/v1/mailbox/"+mailbox)
print(r.text,type(r.text))
global false, null, true
false = null = true = ''
email_id = list(eval(r.text))[0]['id']
# r =session.get('https://www.linshiyouxiang.net/mailbox/kh8l6u6_/5c9d9298cfcdca2d52d7c13d')
r =session.get('https://www.linshiyouxiang.net/mailbox/'+mailbox+'/'+email_id)
doc = etree.HTML(r.text)
code = doc.xpath("//td[@id='verificationMsg']/p[2]/text()")[0]
print(code)
if __name__ == '__main__':
selum_chrome()