mirror of
https://github.com/Second-Hand-Friends/kleinanzeigen-bot.git
synced 2026-03-13 02:51:49 +01:00
FIX edge case name without link
This commit is contained in:
committed by
Sebastian Thomschke
parent
d7ccc8954b
commit
a50dead2a7
@@ -716,7 +716,7 @@ class KleinanzeigenBot(SeleniumMixin):
|
|||||||
n_images = int(image_counter.text[2:])
|
n_images = int(image_counter.text[2:])
|
||||||
logger.info('Found %d images.', n_images)
|
logger.info('Found %d images.', n_images)
|
||||||
next_button = self.webdriver.find_element(By.CSS_SELECTOR, '.galleryimage--navigation--next')
|
next_button = self.webdriver.find_element(By.CSS_SELECTOR, '.galleryimage--navigation--next')
|
||||||
except NoSuchElementException:
|
except (NoSuchElementException, IndexError):
|
||||||
logger.info('Only one image found.')
|
logger.info('Only one image found.')
|
||||||
|
|
||||||
# download all images from box
|
# download all images from box
|
||||||
|
|||||||
@@ -133,7 +133,10 @@ class AdExtractor:
|
|||||||
|
|
||||||
contact_person_element = self.driver.find_element(By.CSS_SELECTOR, '#viewad-contact')
|
contact_person_element = self.driver.find_element(By.CSS_SELECTOR, '#viewad-contact')
|
||||||
name_element = contact_person_element.find_element(By.CLASS_NAME, 'iconlist-text')
|
name_element = contact_person_element.find_element(By.CLASS_NAME, 'iconlist-text')
|
||||||
name = name_element.find_element(By.TAG_NAME, 'a').text
|
try:
|
||||||
|
name = name_element.find_element(By.TAG_NAME, 'a').text
|
||||||
|
except NoSuchElementException: # edge case: name without link
|
||||||
|
name = name_element.find_element(By.TAG_NAME, 'span').text
|
||||||
contact['name'] = name
|
contact['name'] = name
|
||||||
|
|
||||||
if 'street' not in contact:
|
if 'street' not in contact:
|
||||||
|
|||||||
Reference in New Issue
Block a user