Commit 12487ab1 authored by litaolemo's avatar litaolemo

update

parent 27c7d4a2
...@@ -52,7 +52,7 @@ def send_email_tome(): ...@@ -52,7 +52,7 @@ def send_email_tome():
toaddrs6 = "litao@igengmei.com" toaddrs6 = "litao@igengmei.com"
content = 'hi all:附件为' + str(date) + '的搜索词数据统计结果以及近一周的数据统计结果,请查收!' content = 'hi all:附件为' + str(date) + '的搜索词数据统计结果以及近一周的数据统计结果,请查收!'
zipFile = "/srv/apps/crawler/近一数据统计结果.xls" zipFile = "/srv/apps/crawler/近一数据统计结果.xls"
# out_path = "/srv/apps/crawler/近一周数据统计结果.zip" # out_path = "/srv/apps/crawler/近一周数据统计结果.zip"
# f = zipfile.ZipFile(zipFile, 'w', zipfile.ZIP_DEFLATED) # f = zipfile.ZipFile(zipFile, 'w', zipfile.ZIP_DEFLATED)
# f.write(out_path) # f.write(out_path)
...@@ -289,30 +289,30 @@ if __name__ == "__main__": ...@@ -289,30 +289,30 @@ if __name__ == "__main__":
charset='utf8', charset='utf8',
cursorclass=pymysql.cursors.DictCursor) cursorclass=pymysql.cursors.DictCursor)
zhengxing_cursor = db_zhengxing_eagle.cursor() zhengxing_cursor = db_zhengxing_eagle.cursor()
date = datetime.datetime.now().date() - datetime.timedelta(days=30) # date = datetime.datetime.now().date() - datetime.timedelta(days=30)
sql = 'select keywords,sum(sorted) as nums,uv from api_search_words where is_delete = 0 and create_time = "' + str( # sql = 'select keywords,sum(sorted) as nums,uv from api_search_words where is_delete = 0 and create_time = "' + str(
date) + '" group by keywords order by nums desc' # date) + '" group by keywords order by nums desc'
print(sql) # print(sql)
zhengxing_cursor.execute("set names 'UTF8'") # zhengxing_cursor.execute("set names 'UTF8'")
zhengxing_cursor.execute(sql) # zhengxing_cursor.execute(sql)
data = zhengxing_cursor.fetchall() # data = zhengxing_cursor.fetchall()
#
tup_title = ("关键词", "搜索次数", "uv", "日记数量", "回答数量", "帖子数量") # tup_title = ("关键词", "搜索次数", "uv", "日记数量", "回答数量", "帖子数量")
for name in list(data): # for name in list(data):
word = name.get("keywords", None) # word = name.get("keywords", None)
num = name.get("nums", 0) # num = name.get("nums", 0)
uv = name.get("uv", 0) # uv = name.get("uv", 0)
#
answer_content_num, tractate_content_num, diary_content_num = get_es_word(word) # answer_content_num, tractate_content_num, diary_content_num = get_es_word(word)
tag_names_list.append([word, num, uv, diary_content_num, answer_content_num, tractate_content_num]) # tag_names_list.append([word, num, uv, diary_content_num, answer_content_num, tractate_content_num])
#
all_data_day.append(tup_title) # all_data_day.append(tup_title)
for item in tag_names_list: # for item in tag_names_list:
all_data_day.append(tuple(item)) # all_data_day.append(tuple(item))
#
path = str(date) + ".xls" # path = str(date) + ".xls"
WritrExcel().write_excel(path, tuple(all_data_day)) # WritrExcel().write_excel(path, tuple(all_data_day))
print(u'创建demo.xls文件成功') # print(u'创建demo.xls文件成功')
date = datetime.datetime.now().date() - datetime.timedelta(days=30) date = datetime.datetime.now().date() - datetime.timedelta(days=30)
sql = 'select keywords,sum(sorted) as nums,sum(uv) as uvs from api_search_words where is_delete = 0 and create_time >= "' + str( sql = 'select keywords,sum(sorted) as nums,sum(uv) as uvs from api_search_words where is_delete = 0 and create_time >= "' + str(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment