Skip to content

Commit a7b414c

Browse files
Chnages in Logs UTF-8 encoding
1 parent 9fbb267 commit a7b414c

File tree

2 files changed

+70
-7
lines changed

2 files changed

+70
-7
lines changed

PyQtDesigner/WebScrapper/WebScapper.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,8 @@ def validateUrl(self,url):
6161
return False
6262

6363
def stop(self):
64-
print ('Process running:', self.processGetSource, self.processGetSource.is_alive())
6564
self.processGetSource.terminate()
6665
print ('Process terminated:', self.processGetSource, self.processGetSource.is_alive())
67-
# self.processGetSource.join()
68-
# print ('Process joined:', self.processGetSource, self.processGetSource.is_alive())
69-
# print ('Process exit code:', self.processGetSource.exitcode)
7066
self.buttonGetInput.setEnabled(True)
7167

7268
# This function will scrap it is also recurive if required
@@ -90,6 +86,7 @@ def getSource(self):
9086
url = self.validateUrl(self.r.html._next())
9187
if url:
9288
if self.r.status_code == 200:
89+
# self.listWidgetLogs.addItem('\n'+self.r.html._next())
9390
self.getSource()
9491

9592

@@ -111,7 +108,11 @@ def getInput(self):
111108
self.listWidgetMain.addItem(self.xpathSrc)
112109
self.processGetSource = multiprocessing.Process(target=self.getSource())
113110
self.processGetSource.start()
114-
# self.getSource()
111+
self.processGetSource.join()
112+
print ('Process joined:', self.processGetSource, self.processGetSource.is_alive())
113+
print ('Process exit code:', self.processGetSource.exitcode)
114+
if self.processGetSource.exitcode == 0:
115+
self.stop()
115116
elif url is None or len(url) < 5:
116117
timestampDay = self.getTimeStamp()
117118
self.listWidgetLogs.addItem(timestampDay)
@@ -124,8 +125,14 @@ def getInput(self):
124125
# Saves logs from Preserved logs
125126
def saveLogs(self):
126127
timestampDay = datetime.now().strftime("%A %d %B %Y %I %M %S%p")
127-
file = open(self.scriptDir + os.path.sep +'WebScrappingLogs '+ timestampDay +'.txt','a+')
128-
128+
fileName = self.scriptDir + os.path.sep +'WebScrappingLogs '+ timestampDay +'.txt'
129+
file = open(fileName,'a+' , encoding='utf-8')
130+
131+
file.writelines('Command Logs ' + timestampDay)
132+
for i in range(self.listWidgetMain.count()):
133+
file.writelines(self.listWidgetMain.item(i).text() + '\n')
134+
135+
file.writelines('\nSource Logs')
129136
for i in range(self.listWidgetLogs.count()):
130137
file.writelines(self.listWidgetLogs.item(i).text() + '\n')
131138
# file.writelines(itemsTextList)
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//p[@class="title"]//a[@href]//text()
2+
Tuesday 09. October 2018 02:58:06 PM
3+
Turning off trending notifications:
4+
self.ProgrammerHumor
5+
[META] New Rules and Mod Applications
6+
self.ProgrammerHumor
7+
Everytime I code in C!
8+
i.redd.it
9+
using his knowledge for other than printing hello world.
10+
i.redd.it
11+
When US debt reaches MAX int64, the world would have to pay them $9223372036854775807 instead 🤔
12+
i.redd.it
13+
Hard to swallow 😂
14+
i.redd.it
15+
The one true way to name variables
16+
i.redd.it
17+
JavaScript
18+
i.redd.it
19+
Abandon all hope ye who enter here
20+
i.redd.it
21+
When you can’t fix a bug so you just cancel the whole project
22+
i.imgur.com
23+
:q!
24+
i.redd.it
25+
We still hating on Eclipse?
26+
i.redd.it
27+
Just C/C++ things
28+
i.redd.it
29+
1960's Employment ad for Programmers... Wonder how Stuart is doing now?
30+
i.redd.it
31+
UNIX sub names
32+
i.redd.it
33+
Expectation vs. Grim Reality
34+
i.redd.it
35+
People don't change
36+
i.redd.it
37+
Javascript dreams
38+
i.redd.it
39+
This world would be much better with a source code...
40+
i.redd.it
41+
test driven development
42+
i.redd.it
43+
OnE dOeS nOt sImpLY eXIt vIm
44+
i.imgflip.com
45+
Node like this
46+
i.redd.it
47+
Don't diss him (x-post r/memes)
48+
i.redd.it
49+
Lua, but in wingdings.
50+
i.redd.it
51+
The harsh reality of programmers (Not Meme)
52+
i.redd.it
53+
Alright, thanks.
54+
i.redd.it
55+
ReGeX
56+
i.redd.it

0 commit comments

Comments
 (0)