标签:port find com sel pytho textarea rom path user
Python代码如下:
# coding=utf-8 from selenium import webdriver from time import sleep from random import randint def auto_throw(username, password): """自动循环扔瓶子""" driver = webdriver.Chrome() driver.get("https://mail.qq.com")
driver.maxmize_window() # 最大化窗口 sleep(1) # 切换iframe表单 driver.switch_to.frame("login_frame") driver.find_element_by_xpath(‘//*[@id="u"]‘).send_keys(username) # 用户名 driver.find_element_by_xpath(‘//*[@id="p"]‘).send_keys(password) # 密码 driver.find_element_by_xpath(‘//*[@id="login_button"]‘).click() # 登录 # 将表单切回到最外层 driver.switch_to.default_content() sleep(2) i = 0 m = 0 # 循环扔瓶子 while True: try: driver.find_element_by_xpath(‘//*[@id="folder_11"]/b[1]‘).click() # 漂流瓶 sleep(1) # 切换iframe表单 driver.switch_to.frame("mainFrame") sleep(1) driver.find_element_by_xpath(‘//*[@id="toolbar"]/div/a[1]‘).click() # 扔一个 sleep(1) driver.find_element_by_xpath(‘//*[@id="bottle_magic"]/div/div[1]/a[1]/span‘).click() # 普通瓶 sleep(1) driver.find_element_by_xpath(‘//*[@id="bottle_send"]/div[2]/div[1]/div[4]/div[2]/div[1]/textarea‘).send_keys("陌生人,
你的幸运数字是%d!"%randint(1,10000)) sleep(2) driver.find_element_by_xpath(‘//*[@id="bottle_send"]/div[2]/div[2]/div[3]/a[2]‘).click() # 扔出去 # 将表单切回到最外层 driver.switch_to.default_content() m += 1 print("第%d个瓶子成功扔出!"%m) sleep(2) except: print("扔瓶子失败或者扔瓶子机会用完了!") i += 1 if i > 10: print("扔瓶子机会用完了!") break if __name__ == ‘__main__‘:
print("--------自动循环丢QQ邮箱漂流瓶脚本--------")
username = input("输入你的QQ邮箱用户名:")
password = input("输入你的QQ邮箱登录密码:")
auto_throw(username, password)
标签:port find com sel pytho textarea rom path user
原文地址:https://www.cnblogs.com/chenbin93/p/9103175.html