From 4de92bd661f71f58ba8207fa7da99b8530668f8c Mon Sep 17 00:00:00 2001 From: Nils Herde Date: Sat, 13 May 2017 13:22:29 +0200 Subject: [PATCH] Quickfix for slash in note names --- itl_scrape.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/itl_scrape.py b/itl_scrape.py index 7bd2070..61b7f0b 100644 --- a/itl_scrape.py +++ b/itl_scrape.py @@ -224,9 +224,15 @@ class itslearning_scraper(): text = self.html2text.handle(str(text)) fp = os.path.join(os.path.abspath(os.path.curdir), title) #convert to md? - with open(fp+".md", "wb") as note: - note.write(bytes(text.encode("utf-8"))) - note.close() + try: + with open(fp+".md", "wb") as note: + note.write(bytes(text.encode("utf-8"))) + note.close() + except FileNotFoundError: + if "/" in title: + print("File contains slash '%s'. Skipping" % title) + else: + print("File not found '%s'" % title) def find_files(self,folders): for link in folders.find_all('a'):