박은주

Add txt type output

Showing 1 changed file with 20 additions and 15 deletions
...@@ -34,8 +34,8 @@ def TextPreprocess(text): ...@@ -34,8 +34,8 @@ def TextPreprocess(text):
34 34
35 def GetData(): 35 def GetData():
36 login_info = { 36 login_info = {
37 - 'userID' : '**********', 37 + 'userID' : 'qdw0313',
38 - 'userpw' : '**********' 38 + 'userpw' : 'fejUfrQxHWwtcGcP0'
39 } 39 }
40 40
41 options = webdriver.ChromeOptions() 41 options = webdriver.ChromeOptions()
...@@ -108,19 +108,24 @@ def GetData(): ...@@ -108,19 +108,24 @@ def GetData():
108 break 108 break
109 break 109 break
110 110
111 - post_df.to_csv('data.csv', mode='w', encoding='utf-8-sig', index=False) 111 + # post_df.to_csv('data.csv', mode='w', encoding='utf-8-sig', index=False)
112 - print("CVS file saved") 112 + # print("CVS file saved")
113 - 113 + #
114 - with open('data.json', 'w+', encoding='utf-8-sig') as json_file: 114 + # with open('data.json', 'w+', encoding='utf-8-sig') as json_file:
115 + # for post in zip(post_df['title'].tolist(), post_df['content'].tolist()):
116 + # json.dump({
117 + # "document" :
118 + # {
119 + # "type" : "PLAIN_TEXT",
120 + # "content" : post[0] + post[1]
121 + # },
122 + # "encodingType" : "UTF8"
123 + # }, json_file, ensure_ascii=False)
124 + # print("JSON file saved")
125 +
126 + with open('data.txt', 'w', encoding='utf-8-sig') as txt_file:
115 for post in zip(post_df['title'].tolist(), post_df['content'].tolist()): 127 for post in zip(post_df['title'].tolist(), post_df['content'].tolist()):
116 - json.dump({ 128 + txt_file.write(post[0] + post[1] + '.\n')
117 - "document" : 129 + print("txt file saved")
118 - {
119 - "type" : "PLAIN_TEXT",
120 - "content" : post[0] + post[1]
121 - },
122 - "encodingType" : "UTF8"
123 - }, json_file, ensure_ascii=False)
124 - print("JSON file saved")
125 130
126 GetData() 131 GetData()
...\ No newline at end of file ...\ No newline at end of file
......