修复爬虫bug

This commit is contained in:
YYL469
2024-07-03 19:49:32 +08:00
parent 4fae040c3e
commit 1edb52a52b
4 changed files with 4 additions and 5 deletions
Binary file not shown.
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
id,likeNum,commentsLen,reposts_count,region,content,contentLen,created_at,type,detailUrl,authorAvatar,authorName,authorDetail,isVip
1 id likeNum commentsLen reposts_count region content contentLen created_at type detailUrl authorAvatar authorName authorDetail isVip
+4 -4
View File
@@ -20,13 +20,13 @@ def save_to_sql():
concatArticlePd.to_sql('article', con=engine, if_exists='replace', index=False) concatArticlePd.to_sql('article', con=engine, if_exists='replace', index=False)
concatCommentsPd.to_sql('comments', con=engine, if_exists='replace', index=False) concatCommentsPd.to_sql('comments', con=engine, if_exists='replace', index=False)
except: except:
articleNewPd = pd.read_csv('articleData.csv') articleNewPd = pd.read_csv('article.csv')
commentNewPd = pd.read_csv('articleComments.csv') commentNewPd = pd.read_csv('comments.csv')
articleNewPd.to_sql('article',con=engine,if_exists='replace',index=False) articleNewPd.to_sql('article',con=engine,if_exists='replace',index=False)
commentNewPd.to_sql('comments',con=engine,if_exists='replace',index=False) commentNewPd.to_sql('comments',con=engine,if_exists='replace',index=False)
os.remove('./articleData.csv') os.remove('./article.csv')
os.remove('./articleComments.csv') os.remove('./comments.csv')
if __name__ == '__main__': if __name__ == '__main__':
save_to_sql() save_to_sql()