Commit d2216340 authored by litaolemo's avatar litaolemo

update

parent ec349855
...@@ -9,3 +9,9 @@ ...@@ -9,3 +9,9 @@
6. 写入抓取url程序 python /srv/apps/crawler/crawler_sys/framework/write_releasers_to_redis.py -p weibo -d 1 -proxies 2 6. 写入抓取url程序 python /srv/apps/crawler/crawler_sys/framework/write_releasers_to_redis.py -p weibo -d 1 -proxies 2
##搜索页爬虫 ##搜索页爬虫
pass
## 数据周报
1. 切换权限 sudo su - gmuser
2. source /root/anaconda3/bin/activate
3. python crawler/crawler_sys/utils/get_query_result.py
\ No newline at end of file
...@@ -57,8 +57,8 @@ def send_email_tome(): ...@@ -57,8 +57,8 @@ def send_email_tome():
f.write(out_path) f.write(out_path)
f.close() f.close()
#zipFile = '昨日数据统计结果.xls' #zipFile = '昨日数据统计结果.xls'
send_file_email(out_path,"",email_group=["litao@igengmei.com"],title_str=content send_file_email("","",email_group=["litao@igengmei.com"],title_str=content
,email_msg_body_str=content) ,email_msg_body_str=content,file=out_path)
except Exception as e: except Exception as e:
print(e) print(e)
......
...@@ -28,7 +28,7 @@ from email.mime.text import MIMEText ...@@ -28,7 +28,7 @@ from email.mime.text import MIMEText
def send_file_email(file_path, data_str, email_group=[], def send_file_email(file_path, data_str, email_group=[],
email_msg_body_str=None, email_msg_body_str=None,
title_str=None, title_str=None,
cc_group=["litao@igengmei.com"], sender=None): cc_group=["litao@igengmei.com"], sender=None,file=None):
directory = file_path directory = file_path
# Create the enclosing (outer) message # Create the enclosing (outer) message
if email_msg_body_str == None: if email_msg_body_str == None:
...@@ -49,8 +49,42 @@ def send_file_email(file_path, data_str, email_group=[], ...@@ -49,8 +49,42 @@ def send_file_email(file_path, data_str, email_group=[],
outer['From'] = sender outer['From'] = sender
mail_service = 'smtp.exmail.qq.com' mail_service = 'smtp.exmail.qq.com'
outer.attach(MIMEText(email_msg_body)) outer.attach(MIMEText(email_msg_body))
if file:
if directory: if not os.path.isfile(file):
pass
file_path,file_name = os.path.split(file)
# Guess the content type based on the file's extension. Encoding
# will be ignored, although we should check for simple things like
# gzip'd or compressed files.
ctype, encoding = mimetypes.guess_type(file)
if ctype is None or encoding is not None:
# No guess could be made, or the file is encoded (compressed), so
# use a generic bag-of-bits type.
ctype = 'application/octet-stream'
maintype, subtype = ctype.split('/', 1)
# if maintype == 'text':
## with open(path,encoding='utf-8') as fp:
### Note: we should handle calculating the charset
## msg = MIMEText(fp.read(), _subtype=subtype)
# continue
if maintype == 'image':
# with open(path, 'rb') as fp:
# msg = MIMEImage(fp.read(), _subtype=subtype)
pass
elif maintype == 'audio':
# with open(path, 'rb') as fp:
# msg = MIMEAudio(fp.read(), _subtype=subtype)
pass
else:
with open(file, 'rb') as fp:
msg = MIMEBase(maintype, subtype, charset='gb18030')
msg.set_payload(fp.read())
# Encode the payload using Base64
encoders.encode_base64(msg)
# Set the filename parameter
msg.add_header('Content-Disposition', 'attachment', filename=file_name)
outer.attach(msg)
elif directory:
for filename in os.listdir(directory): for filename in os.listdir(directory):
path = os.path.join(directory, filename) path = os.path.join(directory, filename)
if not os.path.isfile(path): if not os.path.isfile(path):
......
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