• work-python 脚本 每日发送数据查询


    #!/usr/bin/env python
    # -*- coding:utf-8 -*-
    JG=''
    import pymysql
    import os
    import pymongo
    import datetime

    T=datetime.date.today()
    T1=T-datetime.timedelta(days=1)
    now_T=str(T)+' 00:00:00'
    yes_T=str(T1)+' 00:00:00'

    with pymysql.Connect(host='127.0.0.1',port=3306,user='123',password='123',database='xxx',charset='utf8').cursor() as cursor:
    v1=cursor.execute('SELECT count(id) from publics;')
    GZH_all=str(cursor.fetchall()[0][0]) 
    # print(GZH_all)
    v2=cursor.execute('SELECT count(id) FROM `publics` where status>0;')
    GZH_ok=str(cursor.fetchall()[0][0])
    # print(GZH_ok[0][0])
    v2 = cursor.execute('SELECT count(id) FROM `publics` where `status`=5;')
    GZH_oklist = str(cursor.fetchall()[0][0])
    # print(GZH_oklist[0][0])
    JG+='所有:'+GZH_all
    JG+='-----------有效的:'+GZH_ok
    JG+='----------已经爬取连接的:'+GZH_oklist


    with pymongo.MongoClient('mongodb://aaa:xxx@127.0.0.1:27017/aaa') as client:
    # db = client.js_send_excel
    db=client.weixin
    Acount=db.content
    XQ=str(Acount.count({'status':3})) #总共详情数量
    WZ=str(Acount.count({'status':{"$ne":3}})) #文章数量
    SX=str(Acount.count({'status':{"$lt":0}})) #失效

    JG+='----------总共详情数量:'+XQ
    JG+='---------文章数量:'+WZ
    JG+='----------已失效:'+SX

    #每日
    XQ_day=str(Acount.count({'status':3,'crawl_time':{'$gt':yes_T,"$lt":now_T}}))
    JG+='-----------每日增加详情数:'+XQ_day

    FaSong='/mnt/crontab/sendEmail-v1.56/sendEmail -f xxxx@163.com -t 1111@qq.com -s smtp.163.com -u "每日爬虫情况" -xu xxxx -xp xxx963 -m '+JG

    os.system(FaSong)

  • 相关阅读:
    20165334 我期待的师生关系
    20165228 我期望的师生关系
    20165232 预备作业3 Linux安装及学习
    20165232 学习基础和c语言基础调查
    20165232 我期望的师生关系
    20165320 第一周学习总结
    20165320 预备作业3 :Linux安装及命令入门
    20165320 预备作业2:技能学习心得与C语言学习
    20165320 我期望的师生关系
    20165203 学习基础和C语言基础调查
  • 原文地址:https://www.cnblogs.com/onda/p/7412395.html
Copyright © 2020-2023  润新知