热线电话:13121318867

登录
2019-04-10 阅读量: 574
python如何设置自动祝福

随身携带手机。从whatsapp顶部栏中选择whatsapp web(3个点)

Screenshot2

然后运行脚本(确保已添加chromedriver的绝对路径并已将您的朋友名称替换为目标变量)。from selenium import webdriver

from selenium.webdriver.support.ui import WebDriverWait

from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.common.keys import Keys

from selenium.webdriver.common.by import By

import time

# Replace below path with the absolute path

# to chromedriver in your computer

driver = webdriver.Chrome('/home/saket/Downloads/chromedriver')

driver.get("https://web.whatsapp.com/")

wait = WebDriverWait(driver, 600)

# Replace 'Friend's Name' with the name of your friend

# or the name of a group

target = '"Friend\'s Name"'

# Replace the below string with your own message

string = "Message sent using Python!!!"

x_arg = '//span[contains(@title,' + target + ')]'

group_title = wait.until(EC.presence_of_element_located((

By.XPATH, x_arg)))

group_title.click()

inp_xpath = '//div[@class="input"][@dir="auto"][@data-tab="1"]'

input_box = wait.until(EC.presence_of_element_located((

By.XPATH, inp_xpath)))

for i in range(100):

input_box.send_keys(string + Keys.ENTER)

time.sleep(1)

0.0000
1
关注作者
收藏
评论(0)

发表评论

暂无数据
推荐帖子