Skip to content

Commit 207f44b

Browse files
committed
Bugs fixed for GH-7
Signed-off-by: MikeMeliz <[email protected]>
1 parent d898487 commit 207f44b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

modules/extractor.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,21 @@ def cinex(inputFile, outpath):
1818
for line in f:
1919

2020
# Generate name for every file
21-
pagename = line.rsplit('/', 1)
22-
clpagename = str(pagename[1])
23-
clpagename = clpagename[:-1]
24-
if len(clpagename) == 0:
25-
outputFile = "index.htm"
26-
else:
27-
outputFile = clpagename
21+
try:
22+
pagename = line.rsplit('/', 1)
23+
clpagename = str(pagename[1])
24+
clpagename = clpagename[:-1]
25+
if len(clpagename) == 0:
26+
outputFile = "index.htm"
27+
else:
28+
outputFile = clpagename
29+
except IndexError as e:
30+
print("Error: %s" % e)
31+
continue
2832

2933
# Extract page to file
3034
try:
31-
f = open(outpath + "/" + outputFile, 'w')
35+
f = open(outpath + "/" + outputFile, 'wb')
3236
f.write(urllib.request.urlopen(line).read())
3337
f.close()
3438
print(("## File created on " + os.getcwd() + "/" + outpath + "/" + outputFile))
@@ -53,7 +57,7 @@ def outex(website, outputFile, outpath):
5357
# Extract page to file
5458
try:
5559
outputFile = outpath + "/" + outputFile
56-
f = open(outputFile, 'w')
60+
f = open(outputFile, 'wb')
5761
f.write(urllib.request.urlopen(website).read())
5862
f.close()
5963
print(("## File created on " + os.getcwd() + "/" + outputFile))

0 commit comments

Comments
 (0)