@@ -68,38 +68,48 @@ def getSource(self):
6868 self .getSource ()
6969 except ValueError :
7070 raise InvalidSelector ()
71- exit ()
71+
7272
7373 # Get button function connection
7474 def getInput (self ):
7575 url = self .textEditUrl .toPlainText ()
7676 self .xpathSrc = self .textEditSource .toPlainText ()
77-
78- if url and self .xpathSrc is not None :
77+ print ( self . xpathSrc )
78+ if url and self .xpathSrc . strip () :
7979 source = self .validateUrl (url )
8080 if source :
81+ timestampDay = self .getTimeStamp ()
82+ self .listWidgetLogs .addItem (timestampDay )
8183 self .listWidgetMain .addItem (self .xpathSrc )
8284 self .getSource ()
8385 elif url is None or len (url ) < 5 :
8486 timestampDay = self .getTimeStamp ()
8587 self .listWidgetLogs .addItem (timestampDay )
86- self .listWidgetLogs .addItem ('Url cannot be empty ¯\_(ツ)_/¯ \n ' )
87- elif self .xpathSrc is None :
88- self .listWidgetLogs .addItem ('xpath input \_(ʘ_ʘ)_/ ? ' )
88+ self .listWidgetLogs .addItem ('Url cannot be empty ¯\_(ツ)_/¯ ' )
89+ else :
90+ timestampDay = self .getTimeStamp ()
91+ self .listWidgetLogs .addItem (timestampDay )
92+ self .listWidgetLogs .addItem ('xpath input \_(ʘ_ʘ)_/ where is it ?' )
8993
9094 # Saves logs from Preserved logs
9195 def saveLogs (self ):
92- timestampDay = datetime .now ().strftime ("%A, %d. %B %Y %I:%M:%S %p" )
93- file = open (self .scriptDir + os .path .sep + 'WebScrappingLogs_' + timestampDay + '.txt' ,'a+' )
96+ timestampDay = datetime .now ().strftime ("%A %d %B %Y %I %M %S %p" )
97+ file = open (self .scriptDir + os .path .sep + 'WebScrappingLogs ' + timestampDay + '.txt' ,'a+' )
9498 i = 0
95- for log in self .listWidgetLogs .item (i ).text ():
96- file .write (log + '\n ' )
97- i += 1
99+ logsList = []
100+ itemsTextList = [str (self .listWidgetLogs .item (i ).text ()) for i in range (self .listWidgetLogs .count ())]
101+
102+ # for log in self.listWidgetLogs.item(i).text():
103+ # i = i+ 1
104+ # print(log)
105+ # file.writelines(log)
106+ file .writelines (itemsTextList )
98107 file .close ()
99108 self .listWidgetLogs .addItem ('Logs saved Sucessfully' )
100109
101110 def stop (self ):
102111 self .stop = True
112+ # os.system("pause")
103113
104114 # clear preservedLogs
105115 def clearLogs (self ):
0 commit comments