Commit 5782ab0c authored by 段英荣's avatar 段英荣

增加搜索爬取功能

parent 6af82443
...@@ -248,19 +248,19 @@ class ZhihuAccount(object): ...@@ -248,19 +248,19 @@ class ZhihuAccount(object):
if "data" in raw_content_dict: if "data" in raw_content_dict:
for data_item in raw_content_dict["data"]: for data_item in raw_content_dict["data"]:
type = data_item["obeject"]["type"] data_type = data_item["obeject"]["type"]
content = data_item["object"]["content"] content = data_item["object"]["content"]
platform_id = data_item["object"]["id"] platform_id = data_item["object"]["id"]
user_id = random.choice(majia_user_list) user_id = random.choice(majia_user_list)
question_id = "" question_id = ""
if type == "article": if data_type == "article":
title = data_item["object"]["title"] title = data_item["object"]["title"]
elif type == "answer": elif data_type == "answer":
title = data_item["object"]["question"]["name"] title = data_item["object"]["question"]["name"]
question_id = data_item["object"]["question"]["id"] question_id = data_item["object"]["question"]["id"]
else: else:
print("type is:%s" % type) print("type is:%s" % data_type)
title = "" title = ""
item_dict = { item_dict = {
...@@ -268,7 +268,7 @@ class ZhihuAccount(object): ...@@ -268,7 +268,7 @@ class ZhihuAccount(object):
"platform_id": platform_id, "platform_id": platform_id,
"title": title, "title": title,
"content": content, "content": content,
"type": type, "type": data_type,
"question_id": question_id "question_id": question_id
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment