sql="""select id, content, created_time, comment_count from zhihu_answer"""
self.cur.execute(sql)
...
...
@@ -705,6 +726,7 @@ class Crawler_zhihu():
root_comment=self.cur.fetchall()
comment=[]
forjinrange(len(root_comment)):
reply=[]
ifroot_comment[j][1]!=0:
sql="""select child_comment_id, content, created_time, author_id from zhihu_child_comment as a where a.root_comment_id = '{}' """.format(root_comment[j][0])
self.cur.execute(sql)
...
...
@@ -732,6 +754,7 @@ class Crawler_zhihu():
)
returntopics
#封装文章最终数据结果格式
defarticle_data_complex(self):
sql="""select id, content, created_time, comment_count from zhihu_article"""
self.cur.execute(sql)
...
...
@@ -747,6 +770,7 @@ class Crawler_zhihu():
root_comment=self.cur.fetchall()
comment=[]
forjinrange(len(root_comment)):
reply=[]
ifroot_comment[j][1]!=0:
sql="""select child_comment_id, content, created_time, author_id from zhihu_child_comment as a where a.root_comment_id = '{}' """.format(root_comment[j][0])
self.cur.execute(sql)
...
...
@@ -774,6 +798,7 @@ class Crawler_zhihu():
)
returntopics
#封装回答最终数据结果格式
defthought_data_complex(self):
sql="""select id, content, created_time, comment_count from zhihu_thought"""