python登录网页版微信发送消息

# coding=utf-8
import datetime
import time
from selenium import webdriver

url = "https://wx2.qq.com/?&lang=zh_CN"

browser = webdriver.Chrome()
browser.get("https://wx2.qq.com/?&lang=zh_CN")

time.sleep(13)

search = browser.find_element_by_xpath('//*[@id="search_bar"]/input')
print('这是点击微信')
search.send_keys('微信昵称')
time.sleep(3)
item = browser.find_element_by_xpath('//*[@id="mmpop1"]/div/div[1]/div/div[3]/div/div/div[2]/h4')
item.click()

for i in range(200):
    textarea = browser.find_element_by_xpath('//*[@id="editArea"]')
    textarea.send_keys("服不服")
    submit = browser.find_element_by_xpath('//*[@id="chatArea"]/div[3]/div[3]/a')
    submit.click()
    #time.sleep(1)
    textarea.send_keys(
        "以后还和不和我刷屏了")
    submit = browser.find_element_by_xpath('//*[@id="chatArea"]/div[3]/div[3]/a')

    submit.click()
    time.sleep(1)

time.sleep(55)
browser.quit()

 

posted @ 2019-02-17 15:32  jiyanjiao  阅读(782)  评论(0编辑  收藏  举报