第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > python调用微信截图_python-通过微信接口API定时发送信息/截图

python调用微信截图_python-通过微信接口API定时发送信息/截图

时间:2023-09-07 01:54:57

相关推荐

python调用微信截图_python-通过微信接口API定时发送信息/截图

#导入模块

import datetime

import time

import itchat

from PIL import ImageGrab

from apscheduler.schedulers.blocking import BlockingScheduler

from selenium import webdriver

#登录微信获取用户名

itchat.auto_login(hotReload=True)

#users = itchat.search_friends(name=‘XX’) # 使用备注名来查找实际用户名

#userName0 =users[0][‘UserName’] #获取UserName,用于发送消息

iRoom = itchat.search_chatrooms(name=“YY”)# 使用群名来查找群

userName=iRoom[0][‘UserName’]

#print(iRoom)

#定义job

def send_news():

time1 = datetime.datetime.now()

nowtime=datetime.datetime.strftime(time1,’%Y-%m-%d %H:%M’)

url="https://"#网址1

ur2="https://" #网址2

ur3="https://" #网址3

driver=webdriver.Chrome()

driver.maximize_window()

driver.get(url)

time.sleep(5)

im=ImageGrab.grab((50,260,1800,930))

#report1.show()

im.save(r'C:\Users\Administrator\Desktop\report1.jpg')

driver.quit()

time.sleep(2)

driver=webdriver.Chrome()

driver.maximize_window()

driver.get(ur2)

time.sleep(5)

im=ImageGrab.grab((50,260,1860,930))

#report2.show()

im.save(r'C:\Users\Administrator\Desktop\report2.jpg')

driver.quit()

time.sleep(2)

driver=webdriver.Chrome()

driver.maximize_window()

driver.get(ur3)

time.sleep(5)

im=ImageGrab.grab((50,260,1285,670))

#report3.show()

im.save(r'C:\Users\Administrator\Desktop\report3.jpg')

driver.quit()

time.sleep(2)

itchat.send("以下为"+str(nowtime)+"数据:",toUserName = userName )

itchat.send_image(r'C:\Users\Administrator\Desktop\report1.jpg',toUserName=userName)

itchat.send_image(r'C:\Users\Administrator\Desktop\report2.jpg',toUserName=userName)

itchat.send_image(r'C:\Users\Administrator\Desktop\report3.jpg',toUserName=userName)

#每小时执行一次

Sche=BlockingScheduler()

Sche.remove_all_jobs

Sche.add_job(send_news,‘cron’, day_of_week=‘sat’,hour=‘9’,minute=‘00’,second=‘00’)

#Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘9’,minute=‘35’,second=‘59’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘11’,minute=‘30’,second=‘00’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘14’,minute=‘00’,second=‘00’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘16’,minute=‘00’,second=‘00’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘18’,minute=‘00’,second=‘00’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘20’,minute=‘00’,second=‘00’)

Sche.add_job(send_news,‘cron’, day_of_week=‘mon-sat’,hour=‘22’,minute=‘00’,second=‘00’)

Sche.start()

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。