-
Notifications
You must be signed in to change notification settings - Fork 23
/
PostHandle.py
45 lines (37 loc) · 1.33 KB
/
PostHandle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# -*- coding: utf-8 -*-
from DgSpider.mysqlUtils import dbhandle_get_content
from DgSpider.mysqlUtils import dbhandle_update_status
from DgSpider.uploadUtils import upload_post
import json
def post_handel(url):
result = dbhandle_get_content(url)
title = result[0]
content = result[1]
user_id = result[2]
gid = result[3]
cs = []
text_list = content.split('[dgimg]')
for text_single in text_list:
text_single_c = text_single.split('[/dgimg]')
if len(text_single_c) == 1:
cs_json = {"c": text_single_c[0], "i": '', "w": '', "h": ''}
cs.append(cs_json)
else:
# tmp_img_upload_json = upload_img_result.pop()
pic_flag = text_single_c[1]
img_params = text_single_c[0].split(';')
i = img_params[0]
w = img_params[1]
h = img_params[2]
cs_json = {"c": pic_flag, "i": i, "w": w, "h": h}
cs.append(cs_json)
strcs = json.dumps(cs)
json_data = {"apisign": "99ea3eda4b4554adag2c4a741d58baa60",
"user_id": user_id,
"gid": gid,
"t": title,
"cs": strcs}
# 上传帖子
result_uploadpost = upload_post(json_data)
# 更新状态2,成功上传帖子
result_updateresult = dbhandle_update_status(url, 2)