Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
crawler
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
backend
crawler
Commits
d2216340
Commit
d2216340
authored
Aug 03, 2020
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ec349855
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
5 deletions
+46
-5
README.md
README.md
+7
-0
get_query_result.py
crawler_sys/utils/get_query_result.py
+2
-2
func_send_email_with_file.py
maintenance/func_send_email_with_file.py
+37
-3
No files found.
README.md
View file @
d2216340
...
...
@@ -9,3 +9,9 @@
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
crawler_sys/utils/get_query_result.py
View file @
d2216340
...
...
@@ -57,8 +57,8 @@ def send_email_tome():
f
.
write
(
out_path
)
f
.
close
()
#zipFile = '昨日数据统计结果.xls'
send_file_email
(
out_path
,
""
,
email_group
=
[
"litao@igengmei.com"
],
title_str
=
content
,
email_msg_body_str
=
content
)
send_file_email
(
""
,
""
,
email_group
=
[
"litao@igengmei.com"
],
title_str
=
content
,
email_msg_body_str
=
content
,
file
=
out_path
)
except
Exception
as
e
:
print
(
e
)
...
...
maintenance/func_send_email_with_file.py
View file @
d2216340
...
...
@@ -28,7 +28,7 @@ from email.mime.text import MIMEText
def
send_file_email
(
file_path
,
data_str
,
email_group
=
[],
email_msg_body_str
=
None
,
title_str
=
None
,
cc_group
=
[
"litao@igengmei.com"
],
sender
=
None
):
cc_group
=
[
"litao@igengmei.com"
],
sender
=
None
,
file
=
None
):
directory
=
file_path
# Create the enclosing (outer) message
if
email_msg_body_str
==
None
:
...
...
@@ -49,8 +49,42 @@ def send_file_email(file_path, data_str, email_group=[],
outer
[
'From'
]
=
sender
mail_service
=
'smtp.exmail.qq.com'
outer
.
attach
(
MIMEText
(
email_msg_body
))
if
directory
:
if
file
:
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
):
path
=
os
.
path
.
join
(
directory
,
filename
)
if
not
os
.
path
.
isfile
(
path
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment