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
3c9a6336
Commit
3c9a6336
authored
Aug 21, 2019
by
zhongshangwu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微博数据入库
parent
f6a5d5d3
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 @
3c9a6336
This diff is collapsed.
Click to expand it.
api/utils/upload.py
View file @
3c9a6336
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