Skip to content

Commit c3df939

Browse files
authored
Merge pull request #27 from yeheshuah/master
File name mismatch when using the Extract option #26
2 parents c83fd53 + 98a0296 commit c3df939

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

torcrawl.py

+16-16
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,21 @@ def main():
169169

170170
args = parser.parse_args()
171171

172+
now = datetime.datetime.now().strftime("%Y%m%d")
173+
174+
# Canonicalization of web url and create path for output.
175+
website = ''
176+
out_path = ''
177+
178+
if len(args.url) > 0:
179+
website = url_canon(args.url, args.verbose)
180+
if args.folder is not None:
181+
out_path = folder(args.folder, args.verbose)
182+
else:
183+
out_path = folder(extract_domain(website), args.verbose)
184+
172185
# Parse arguments to variables else initiate variables.
173-
input_file = args.input if args.input else ''
186+
input_file = args.input if args.input else (out_path + '/' + now + '_links.txt')
174187
output_file = args.output if args.output else ''
175188
c_depth = args.cdepth if args.cdepth else 0
176189
c_pause = args.cpause if args.cpause else 1
@@ -185,30 +198,17 @@ def main():
185198
check_ip()
186199
print(('## URL: ' + args.url))
187200

188-
website = ''
189-
out_path = ''
190-
191-
# Canonicalization of web url and create path for output.
192-
if len(args.url) > 0:
193-
website = url_canon(args.url, args.verbose)
194-
if args.folder is not None:
195-
out_path = folder(args.folder, args.verbose)
196-
else:
197-
out_path = folder(extract_domain(website), args.verbose)
198-
199201
if args.crawl:
200202
crawler = Crawler(website, c_depth, c_pause, out_path, args.log,
201203
args.verbose)
202204
lst = crawler.crawl()
203205

204-
now = datetime.datetime.now().strftime("%Y%m%d")
205-
with open(out_path + '/' + now + '_links.txt', 'w+', encoding='UTF-8') as file:
206+
with open(input_file, 'w+', encoding='UTF-8') as file:
206207
for item in lst:
207208
file.write(f"{item}\n")
208-
print(f"## File created on {os.getcwd()}/{out_path}/links.txt")
209+
print(f"## File created on {os.getcwd()}/{input_file}")
209210

210211
if args.extract:
211-
input_file = out_path + "/links.txt"
212212
extractor(website, args.crawl, output_file, input_file, out_path,
213213
selection_yara)
214214
else:

0 commit comments

Comments
 (0)