Python+selenium自动循环送贺卡
Python源代码如下:
# coding=utf-8 from selenium import webdriver from time import sleep from random import randint def auto_throw(target_qq, username, password): """自动循环送贺卡""" driver = webdriver.Chrome() driver.get("https://mail.qq.com") driver.set_window_size(1100, 580) 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() sleep(1) # 将表单切回到最外层 driver.switch_to.default_content() sleep(2) m =while True: try: m += 1 driver.switch_to.default_content() driver.find_element_by_xpath('//*[@id="folder_card"]').click() # 贺卡 sleep(2) # 切换iframe表单 driver.switch_to.frame("mainFrame") driver.find_element_by_xpath('//*[@id="preview_1072308"]/img').click() # 儿童节 # 将表单切回到最外层 driver.switch_to.default_content() sleep(2) driver.find_element_by_xpath('//div[@class="dialog_operate"]/a').click() # 发送 sleep(2) driver.find_element_by_xpath('//a[@title="%[email protected]"]'%target_qq).click() sleep(1) driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_content"]').clear() driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_content"]').send_keys("第%d张贺卡发送成功!代号%d!"%(m,randint(10000,100000))) sleep(2) driver.find_element_by_xpath('//*[@id="GreetingCard_QMDialog_sendbtn"]').click() # 发送 print("第%d张贺卡发送成功!"%m) sleep(2) except: print("送卡失败!") sleep(2) if __name__ == '__main__': print("--------自动送贺卡脚本--------") target_qq = input("请输入对方qq号:") username = input("输入你的QQ邮箱用户名:") password = input("输入你的QQ邮箱登录密码:") auto_throw(target_qq, username, password)
相关推荐
paleyellow 2020-10-25
baifanwudi 2020-10-25
LxyPython 2020-08-17
fangjack 2020-06-25
云之高水之远 2020-06-20
maowenbei 2020-06-10
tiankele0 2020-06-09
Andrewjdw 2020-05-29
zengni 2020-05-29
Alanxz 2020-05-28
yogoma 2020-05-28
freerocker 2020-05-26
andrewwf 2020-05-08
我欲疾风前行 2020-04-30
坚持是一种品质 2020-04-25
Wmeng0 2020-04-07
sunzhihaofuture 2020-03-27