import peter
This commit is contained in:
25
seek/zhihu_com/demo.py
Normal file
25
seek/zhihu_com/demo.py
Normal file
@ -0,0 +1,25 @@
|
||||
from database.database import get_session
|
||||
from database.thotcontent.crud import get_hot_content_by_topic_id
|
||||
from database.thottopic.crud import get_latest_hot_topic
|
||||
|
||||
if __name__ == '__main__':
|
||||
with get_session() as db:
|
||||
# 1. 获取最新的热点话题
|
||||
latest_hot_topic = get_latest_hot_topic(db)
|
||||
topic = latest_hot_topic.topic
|
||||
print(latest_hot_topic)
|
||||
# 2. 获取话题内容
|
||||
hot_contents = get_hot_content_by_topic_id(db, latest_hot_topic.id)
|
||||
for hot_content in hot_contents:
|
||||
print(hot_content)
|
||||
# 统计hot_content.content的字数
|
||||
print(len(hot_content.content))
|
||||
topic_content = [hot_content.content for hot_content in hot_contents]
|
||||
print(topic_content)
|
||||
print(len(topic_content))
|
||||
print('---------------------------------------------------------------')
|
||||
print(topic_content[0])
|
||||
print('---------------------------------------------------------------')
|
||||
print(topic_content[1])
|
||||
print('---------------------------------------------------------------')
|
||||
print(topic_content[2])
|
||||
Reference in New Issue
Block a user