Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
saturn
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
赵磊
saturn
Commits
41d4fa24
Commit
41d4fa24
authored
Aug 23, 2019
by
钟尚武
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/weibo' into 'master'
微博数据入库 See merge request
alpha/saturn!104
parents
34e29108
12dfbb9a
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
weibo_commands.py
api/management/commands/weibo_commands.py
+0
-0
upload.py
api/utils/upload.py
+24
-0
No files found.
api/management/commands/weibo_commands.py
0 → 100644
View file @
41d4fa24
This diff is collapsed.
Click to expand it.
api/utils/upload.py
View file @
41d4fa24
import
requests
from
gm_upload
import
upload
,
upload_file
from
gm_upload
import
IMG_TYPE
import
io
from
PIL
import
Image
# import numpy as np
def
upload_image
(
url
,
img_type
=
IMG_TYPE
.
TOPIC
):
...
...
@@ -10,3 +13,24 @@ def upload_image(url, img_type=IMG_TYPE.TOPIC):
return
upload
(
response
.
content
,
img_type
=
img_type
)
except
:
return
None
def
upload_weibo_image
(
url
,
img_type
=
IMG_TYPE
.
TOPIC
):
'''非站内图片处理'''
try
:
response
=
requests
.
get
(
url
)
img
=
Image
.
open
(
io
.
BytesIO
(
response
.
content
))
w
,
h
=
img
.
size
img
=
img
.
crop
((
0
,
0
,
w
,
h
-
10
))
# img = img.convert('RGB')
# content = np.array(img)[..., ::-1]
temp
=
io
.
BytesIO
()
# content = Image.fromarray(content)
img
.
save
(
temp
,
format
=
"png"
)
content
=
temp
.
getvalue
()
return
upload
(
content
,
img_type
=
img_type
)
except
:
return
None
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