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
27945ac0
Commit
27945ac0
authored
Jan 13, 2021
by
litaolemo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix
parent
a5fc987c
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
20 deletions
+29
-20
josnfile.json
crawler_sys/scheduler/josnfile.json
+0
-0
xiaohongshu_to_rpc.py
crawler_sys/scheduler/xiaohongshu_to_rpc.py
+29
-20
No files found.
crawler_sys/scheduler/josnfile.json
0 → 100644
View file @
27945ac0
This diff is collapsed.
Click to expand it.
crawler_sys/scheduler/xiaohongshu_to_rpc.py
View file @
27945ac0
...
...
@@ -10,10 +10,10 @@ import random
import
redis
,
json
from
crawler.crawler_sys.utils.rpc_data_to_answer
import
post_single_data
,
post_muilty_data
from
crawler_sys.utils.output_results
import
retry_get_url
from
crawler.gm_upload.gm_upload
import
upload
,
upload_file
#
from crawler.gm_upload.gm_upload import upload, upload_file
gm_user_id_list
=
[
'5cca9b3700000000120314c9'
,
'5cca9b3700000000120314c9'
,
'5aa0f7bae8ac2b65bfcdaf0e'
,
'5c20dd200000000007027c07'
,
'5fe1c1ba0000000001006e65'
]
...
...
@@ -108,34 +108,40 @@ user_id_list = [
31358658
,
]
f
=
open
(
"josnfile.json"
,
"r"
,
encoding
=
'utf-8'
)
rds
=
redis
.
StrictRedis
(
host
=
'172.18.51.10'
,
port
=
6379
,
db
=
17
,
decode_responses
=
True
)
pid_list
=
rds
.
hkeys
(
"xiaohongshu"
)
for
pid
in
pid_list
:
res
=
rds
.
hget
(
"xiaohongshu"
,
pid
)
for
line
in
f
:
# for pid in f:
# res = rds.hget("xiaohongshu", pid)
# if rds.hexists("xiaohongshu_with_img", pid):
# continue
res_json
=
json
.
loads
(
res
)
res_json
=
json
.
loads
(
line
)
video_dic
=
{}
qiniu_img_list
=
[]
print
(
pid
)
for
img_url
in
res_json
[
"NoteView"
][
"content"
][
"imageList"
]:
try
:
img_wb
=
retry_get_url
(
"http:"
+
img_url
[
"url"
]
.
replace
(
img_url
[
'fileId'
],
img_url
[
'traceId'
]))
.
content
res
=
upload
(
img_wb
,
img_type
=
99
)
# print(res)
img_info
=
retry_get_url
(
res
+
"-imageinfo"
)
img_info_json
=
img_info
.
json
()
qiniu_img_list
.
append
(
'<img src="'
+
res
+
'-w">'
)
except
Exception
as
e
:
print
(
"down load img error
%
s"
%
e
)
continue
print
(
res_json
)
pid
=
res_json
[
"NoteView"
][
"id"
]
# for img_url in res_json["NoteView"]["content"]["imageList"]:
# try:
# img_wb = retry_get_url("http:" + img_url["url"].replace(img_url['fileId'],img_url['traceId'])).content
# res = upload(img_wb, img_type=99)
# # print(res)
# img_info = retry_get_url(res + "-imageinfo")
# img_info_json = img_info.json()
# qiniu_img_list.append('<img src="' + res + '-w">')
# except Exception as e:
# print("down load img error %s" % e)
# continue
# print(qiniu_img_list)
try
:
# if True:
desc_fix
=
"<p>"
+
res_json
[
"NoteView"
][
"content"
][
'desc'
]
.
replace
(
'
\n
'
,
'<br>'
)
+
""
.
join
(
qiniu_img_list
)
+
"</p>"
res_json
[
"NoteView"
][
"content"
][
"desc_fix"
]
=
desc_fix
# desc_fix = "<p>" + res_json["NoteView"]["content"]['desc'].replace('\n', '<br>') + "".join(qiniu_img_list) + "</p>"
# res_json["NoteView"]["content"]["desc_fix"] = desc_fix
desc_fix
=
res_json
[
"NoteView"
][
"content"
][
"desc_fix"
]
# print(desc_fix)
res
=
rds
.
hset
(
"xiaohongshu_with_img"
,
key
=
pid
,
value
=
json
.
dumps
(
res_json
))
# f.write(json.dumps(res_json) + "\n")
# f.flush()
# res = rds.hset("xiaohongshu_with_img", key=pid, value=json.dumps(res_json))
if
res_json
[
"NoteView"
][
"author"
][
'id'
]
in
gm_user_id_list
:
video_dic
[
"level"
]
=
"5"
else
:
...
...
@@ -194,3 +200,5 @@ for pid in pid_list:
continue
# break
# f.flush()
# f.close()
\ No newline at end of file
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