爬虫结束自动打标注

This commit is contained in:
juanboy
2024-07-04 16:04:10 +08:00
parent 406939eaaa
commit a61760213b
+6 -6
View File
@@ -39,7 +39,7 @@ def topicdefine():
for x in articleList: for x in articleList:
label_article.append((x[0],predict_topic(x[5]))) label_article.append((x[0],predict_topic(x[5])))
for x in commentList: for x in commentList:
label_comments.append((x[8],predict_topic(x[4]))) label_comments.append((x[5],x[8],predict_topic(x[4])))
return label_article,label_comments return label_article,label_comments
# 更新数据库 # 更新数据库
@@ -53,14 +53,14 @@ def update_data():
params = [str(label),str(id)] params = [str(label),str(id)]
query(sql, params) query(sql, params)
for row in label_comments: for row in label_comments:
id, label = row id,image,label = row
sql = "UPDATE comments SET label = %s WHERE authorName = %s" sql = "UPDATE comments SET label = %s WHERE authorName=%s AND authorAvatar = %s"
params = [str(label),str(id)] params = [str(label),str(id),str(image)]
query(sql, params) query(sql, params)
if __name__ == '__main__': if __name__ == '__main__':
# drop_label()
# drop_label1()
update_data() update_data()
#删除文章和评论的标签列 #删除文章和评论的标签列
# drop_label()
# drop_label1()