• wechat推送CVE内容


    Wechat实现自动推送CVE内容,需关注wechat公众号方糖,获取API

    获取最新CVE,也可以自我优化,进行提取关键字

    import requests
    import json
    import time
    import os
    import pandas as pd
    time_sleep = 20 #每隔20秒爬取一次
    while(True):
        headers = {
            "User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.25 
     Safari/537.36 Core/1.70.3741.400 QQBrowser/10.5.3863.400"}
          #判断文件是否存在
          datas = []
          response1=None
          response2=None
          if os.path.exists("olddata.csv"):
              #如果文件存在则每次爬取10个
              df = pd.read_csv("olddata.csv", header=None)
              datas = df.where(df.notnull(),None).values.tolist()#将提取出来的数据中的nan转化为None
              response1 = requests.get(url="https://api.github.com/search/repositories?q=CVE-2021&sort=updated&per_page=10",
                                       headers=headers)
              response2 = requests.get(url="https://api.github.com/search/repositories?q=RCE&ssort=updated&per_page=10",
                                       headers=headers)
    
      else:
          #不存在爬取全部
          datas = []
          response1 = requests.get(url="https://api.github.com/search/repositories?q=CVE-2021&sort=updated&order=desc",headers=headers)
          response2 = requests.get(url="https://api.github.com/search/repositories?q=ctcms&ssort=updated&order=desc",headers=headers)
    
      data1 = json.loads(response1.text)
      data2 = json.loads(response2.text)
      for j in [data1["items"],data2["items"]]:
          for i in j:
              s = {"name":i['name'],"html":i['html_url'],"description":i['description']}
              s1 =[i['name'],i['html_url'],i['description']]
              if s1 not in datas:
                  #print(s1)
                  #print(datas)
                  params = {
                       "text":s["name"],
                      "desp":" 链接:"+str(s["html"])+"\n简介"+str(s["description"])
                  }
                  print("当前推送为"+str(s)+"\n")
                  print(params)
                  # 此处填写个人wechat API,达到推送
                  requests.get("https://sc.ftqq.com/SCU138135T72db7d28e6a9744f15feab2e110a53d25fe29d8e8e54e.send",params=params,timeout=10)
                  #time.sleep(1)#以防推送太猛
                  print("推送完成!")
                  datas.append(s1)
              else:
                  pass
                  #print("数据已处在!")
      pd.DataFrame(datas).to_csv("olddata.csv",header=None,index=None)
      time.sleep(time_sleep)
  • 相关阅读:
    mysql常用语句、命令(增删改查功能)
    MySQL 入门知识点
    windows下安装mysql解压版
    第4章 HDFS操作
    第3章 Hadoop 2.x分布式集群搭建
    第2章 CentOS7集群环境配置
    第1章 VMware中安装CentOS7
    windows10激活方法
    linux系统下操作mysql数据库常见命令
    xampp搭建开源项目iwebshop后,服务器重启后再启动xampp显示组件都启动ok,但是实际启动失败解决办法
  • 原文地址:https://www.cnblogs.com/SnowSec/p/14656166.html
Copyright © 2020-2023  润新知