• 欢迎光临~

起始链接状态码,没写完先这样

开发技术 开发技术 2022-07-20 次浏览
#!/usr/bin/python
import requests
import json
import time


def return_ztm(url):
    html = requests.get(url)
    respon = html.status_code
    print(respon)
    if respon == 200:
        return True
    else:
        return False




def dd_robot(Tlist,Flist):
      HEADERS = {"Content-Type": "application/json;charset=utf-8"}
      # 之前复制的接口地址和token信息
      url = 'https://oapi.dingtalk.com/robot/send?access_token=6726b6c161c35e66f5028c3adb856ca9f0b973e787cee8acfe6522ddd15b6d76'
      #content里面要设置关键字
      data_info = {
        "msgtype": "text",
        "text": {
        "content": '测试机器人'
        },
        "isAtAll": False
        #这是配置需要@的人
         # ,"at": {"atMobiles": ["15xxxxxx06",'18xxxxxx1']}
      }
      value = json.dumps(data_info)
      response = requests.post(url,data=value,headers=HEADERS)
      if response.json()['errmsg']!='ok':
        print(response.text)

def loop():
    D = {"历史利率水平": "http://www.pbc.gov.cn/zhengcehuobisi/125207/125213/125440/125838/125888/index.html",
         "现行利率水平": "http://www.pbc.gov.cn/zhengcehuobisi/125207/125213/125440/125838/125885/125896/index.html"
        , "现22水平": "http://www.pbc.gov.cn/zhengcehuobisi/125207/12"
         }

    Tdict  = {}
    Fdict = {}

    for i in D.items():
        #元组 0 名字 1链接
        key = i[0]
        value = i[1]
        if return_ztm(value):
            Tdict[key] = value
        else:
            Fdict[key] = value
    print(Tdict,Fdict)



# 按间距中的绿色按钮以运行脚本。
if __name__ == '__main__':
    loop()



程序员灯塔
转载请注明原文链接:起始链接状态码,没写完先这样
喜欢 (0)