亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

python實(shí)現(xiàn)釘釘機(jī)器人自動(dòng)打卡天天早下班

 更新時(shí)間:2022年06月09日 14:42:16   作者:lei.hou  
這篇文章主要為大家介紹了python實(shí)現(xiàn)釘釘機(jī)器人自動(dòng)打卡天天下早班實(shí)例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

一,新建釘釘機(jī)器人

1.釘釘群右上角點(diǎn)擊群設(shè)置,選擇智能群助手,點(diǎn)擊添加機(jī)器人,選擇自定義機(jī)器人;

2.給機(jī)器人起個(gè)名字,消息推送開(kāi)啟,復(fù)制出 webhook,后面會(huì)用到,勾選自定義關(guān)鍵詞,填寫(xiě)關(guān)鍵詞(關(guān)鍵詞可以隨便填寫(xiě),但是一定要記住,后面會(huì)用);

二,釘釘機(jī)器人發(fā)送消息

url 就是創(chuàng)建機(jī)器人時(shí)的 webhook,data 中的 atMobiles 可填寫(xiě)多個(gè)手機(jī)號(hào),發(fā)送的消息會(huì)直接 @ 這個(gè)人,text 的 content 里面一定要加上創(chuàng)建機(jī)器人時(shí)設(shè)置的關(guān)鍵詞,msgtype 意思時(shí)文本格式,也可以 link 格式,就可以放鏈接了;

def send_text(self):
        url = "https://oapi.dingtalk.com/robot/send?access_token=43c4dab2ac31125e605c458b4b9561a73"
        headers = {'Content-Type': 'application/json'}
        data = {"at": {"atMobiles":["18206264857"],"atUserIds":["user123"],"isAtAll": False},
                "text": {"content":"砍價(jià)小程序接口自動(dòng)化測(cè)試"},"msgtype":"text"},"msgtype":"text"}
        requests.post(url,headers=headers,data=json.dumps(data))

三,釘釘機(jī)器人實(shí)際的應(yīng)用

1.監(jiān)控接口自動(dòng)化結(jié)果

實(shí)現(xiàn)思路是:jenkins 定時(shí)執(zhí)行自動(dòng)化——執(zhí)行完后生成 html 報(bào)告——BeautifulSoup 模塊解析 html 報(bào)告——發(fā)送釘釘消息

如下代碼:

解析 html 的模塊:

from common.handle_path import html_path
from bs4 import BeautifulSoup
class GetHtml:
    """
    讀取測(cè)試報(bào)告,解析html  獲得測(cè)試用例總數(shù),通過(guò)數(shù)等,發(fā)送到釘釘
    """
    def get_total(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("p")[1].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_pass(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="passed")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_skipped(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="skipped")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_failed(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="failed")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_error(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="error")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_xfailed(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="xfailed")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
    def get_xpassed(self):
        with open(html_path, "r", encoding="utf-8") as f:
            file = f.read()
            soup = BeautifulSoup(file, 'html.parser')  # 使用BeautifulSoup庫(kù)解析網(wǎng)頁(yè)內(nèi)容
            item = soup.find_all("span",class_="xpassed")[0].string  # 使用BeautifulSoup庫(kù)的標(biāo)簽方法找到你需要的內(nèi)容
            return str(item)
if __name__ == '__main__':
    t = GetHtml()
    t.get_xpassed()

如下代碼:

發(fā)送釘釘消息的模塊:

import requests
import json
from common.handle_readhtml import GetHtml
class SendMassage:
    """
    發(fā)送測(cè)試結(jié)果到釘釘群
    """
    result = GetHtml()
    total = result.get_total()
    passed = result.get_pass()
    skipped = result.get_skipped()
    failed = result.get_failed()
    error = result.get_error()
    xfailed = result.get_xfailed()
    xpassed = result.get_xpassed()
    def send_text(self):
        url = "https://oapi.dingtalk.com/robot/send?access_token=43c4dab2ac3152e605c458b4b9561a73"
        headers = {'Content-Type': 'application/json'}
        data = {"at": {"atMobiles":["18206233880"],"atUserIds":["user123"],"isAtAll": False},
                "text": {"content":"砍價(jià)小程序接口自動(dòng)化測(cè)試 \n total       : {}\n passed   : {},\n skipped : {},\n failed    : {},\n error     : {},\n xfailed   : {},\n xpassed : {}".format(self.total,self.passed,self.skipped,self.failed,self.error,self.xfailed,self.xpassed)},"msgtype":"text"}
        requests.post(url,headers=headers,data=json.dumps(data))
if __name__ == '__main__':
    s = SendMassage()
    s.send_text()

jenkins 配置的 shell 為:

先執(zhí)行接口自動(dòng)化腳本,等待一會(huì)然后發(fā)送釘釘消息;

${PYTHON} main.py
sleep 100
${PYTHON} handle_dingding.py

接口自動(dòng)化發(fā)釘釘群消息還可以再優(yōu)化,比如可以加上斷言失敗的錯(cuò)誤日志等;

2,監(jiān)控 qa 環(huán)境錯(cuò)誤日志

這里貼上周游大佬的一篇博客:http://chabaoo.cn/article/250972.htm

此處發(fā)送的 qq 郵件,消息查看不方便,且不好共享,可以優(yōu)化為發(fā)釘釘群消息,然后將開(kāi)發(fā)也拉到群里,提高效率;

3,jira 上有釘釘機(jī)器人插件,可以每天發(fā)送消息 @ 某某開(kāi)發(fā) 還有 N 個(gè)待處理 bug,@ 某某測(cè)試 還有 N 個(gè)待驗(yàn)證 bug,以及監(jiān)控看板指標(biāo)達(dá)到閾值報(bào)警等;

以上就是python實(shí)現(xiàn)釘釘機(jī)器人自動(dòng)打卡天天下早班的詳細(xì)內(nèi)容,更多關(guān)于python釘釘機(jī)器人打卡的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

最新評(píng)論