Commit 67b86bd3 authored by 李小芳's avatar 李小芳

add

parent 827549ca
...@@ -36,7 +36,7 @@ def send_email_tome(): ...@@ -36,7 +36,7 @@ def send_email_tome():
content = '爬取更美热搜前100的词召回的商品,内容详见表格' content = '爬取更美热搜前100的词召回的商品,内容详见表格'
text_apart = MIMEText(content, 'plain', "utf-8") text_apart = MIMEText(content, 'plain', "utf-8")
zip_file_week = 'gengmei_service.csv' zip_file_week = 'gengmei_service.csv.gz'
zip_apart_week = MIMEApplication(open(zip_file_week, 'rb').read()) zip_apart_week = MIMEApplication(open(zip_file_week, 'rb').read())
zip_apart_week.add_header('Content-Disposition', 'attachment', filename=zip_file_week) zip_apart_week.add_header('Content-Disposition', 'attachment', filename=zip_file_week)
...@@ -49,7 +49,7 @@ def send_email_tome(): ...@@ -49,7 +49,7 @@ def send_email_tome():
m['Subject'] = '新氧商品信息' m['Subject'] = '新氧商品信息'
try: try:
server = smtplib.SMTP_SSL('smtp.exmail.qq.com', 465) server = smtplib.SMTP_SSL('smtp.exmail.qq.com', 465, timeout=1200)
server.login(from_addrs, password) server.login(from_addrs, password)
server.sendmail(from_addrs, [toaddrs], m.as_string()) server.sendmail(from_addrs, [toaddrs], m.as_string())
print('success') print('success')
...@@ -125,7 +125,7 @@ if __name__ == '__main__': ...@@ -125,7 +125,7 @@ if __name__ == '__main__':
all_data = [] all_data = []
city_list = ["北京", "上海", "广州", "深圳", "杭州", "成都", "重庆", "南京", "武汉", "长沙", "郑州", "西安"] city_list = ["北京", "上海", "广州", "深圳", "杭州", "成都", "重庆", "南京", "武汉", "长沙", "郑州", "西安"]
for city_name in city_list: for city_name in city_list:
file_name = "gengmei_save_data_" + today + city_name + ".txt" file_name = "gengmei_save_data_2021-07-22" + city_name + ".txt"
if os.path.exists(file_name): if os.path.exists(file_name):
open_file = open(file_name, "r", encoding="utf-8") open_file = open(file_name, "r", encoding="utf-8")
print(file_name) print(file_name)
...@@ -139,10 +139,8 @@ if __name__ == '__main__': ...@@ -139,10 +139,8 @@ if __name__ == '__main__':
if len(all_data): if len(all_data):
res = pd.DataFrame(all_data) res = pd.DataFrame(all_data)
res.to_csv("gengmei_service.csv", encoding="gb18030") res.to_csv("gengmei_service.csv.gz", compression='gzip', index=False, encoding="gb18030")
# f = zipfile.ZipFile("gengmei_service.csv", "w", zipfile.ZIP_DEFLATED) send_email_tome()
#
# send_email_tome()
print(time.time() - begin) print(time.time() - begin)
print("end") print("end")
...@@ -36,7 +36,7 @@ def send_email_tome(): ...@@ -36,7 +36,7 @@ def send_email_tome():
content = '爬取新氧热搜前100的词召回的商品,内容详见表格' content = '爬取新氧热搜前100的词召回的商品,内容详见表格'
text_apart = MIMEText(content, 'plain', "utf-8") text_apart = MIMEText(content, 'plain', "utf-8")
zip_file_week = 'soyoung_service.csv' zip_file_week = 'soyoung_service.csv.gz'
zip_apart_week = MIMEApplication(open(zip_file_week, 'rb').read()) zip_apart_week = MIMEApplication(open(zip_file_week, 'rb').read())
zip_apart_week.add_header('Content-Disposition', 'attachment', filename=zip_file_week) zip_apart_week.add_header('Content-Disposition', 'attachment', filename=zip_file_week)
...@@ -103,7 +103,7 @@ if __name__ == '__main__': ...@@ -103,7 +103,7 @@ if __name__ == '__main__':
if len(all_data): if len(all_data):
res = pd.DataFrame(all_data) res = pd.DataFrame(all_data)
res.to_csv("soyoung_service.csv", encoding="gb18030") res.to_csv("soyoung_service.csv.gz", compression='gzip', index=False, encoding="gb18030")
send_email_tome() send_email_tome()
print(time.time() - begin) print(time.time() - begin)
......
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