FIX make sure ads base directory exists

This commit is contained in:
Philipp K
2022-11-07 17:43:02 +01:00
committed by Sebastian Thomschke
parent faa71ac03f
commit 8bcd6f9ad8
2 changed files with 5 additions and 2 deletions

View File

@@ -815,8 +815,11 @@ class KleinanzeigenBot(SeleniumMixin):
Downloads an ad to a specific location, specified by config and ad_id. Downloads an ad to a specific location, specified by config and ad_id.
""" """
# create sub-directory for ad to download # create sub-directory for ad to download:
relative_directory = str(self.config['ad_files'][0]).split('**', maxsplit=1)[0] relative_directory = str(self.config['ad_files'][0]).split('**', maxsplit=1)[0]
# make sure configured base directory exists
if not os.path.exists(relative_directory) or not os.path.isdir(relative_directory):
os.mkdir(relative_directory)
new_base_dir = os.path.join(relative_directory, f'ad_{self.ad_id}') new_base_dir = os.path.join(relative_directory, f'ad_{self.ad_id}')
if os.path.exists(new_base_dir): if os.path.exists(new_base_dir):
LOG.info('Deleting current folder of ad...') LOG.info('Deleting current folder of ad...')

View File

@@ -143,7 +143,7 @@ class AdExtractor:
phone_number = phone_element.find_element(By.TAG_NAME, 'a').text phone_number = phone_element.find_element(By.TAG_NAME, 'a').text
contact['phone'] = ''.join(phone_number.replace('-', ' ').split(' ')).replace('+49(0)', '0') contact['phone'] = ''.join(phone_number.replace('-', ' ').split(' ')).replace('+49(0)', '0')
except NoSuchElementException: except NoSuchElementException:
contact['phone'] = None # phone seems to be a deprecated feature contact['phone'] = None # phone seems to be a deprecated feature (for non-professional users)
# also see 'https://themen.ebay-kleinanzeigen.de/hilfe/deine-anzeigen/Telefon/ # also see 'https://themen.ebay-kleinanzeigen.de/hilfe/deine-anzeigen/Telefon/
return contact return contact