#!/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)