python实时脚本_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)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值