From 9c5c31d22ef2176b98531d6ca8207486f2136726 Mon Sep 17 00:00:00 2001 From: kaesinol Date: Sun, 12 Nov 2023 22:21:32 +0800 Subject: [PATCH] fuck u twitter --- twitter_user_tweet_crawler/pool.py | 2 -- twitter_user_tweet_crawler/tweet.py | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/twitter_user_tweet_crawler/pool.py b/twitter_user_tweet_crawler/pool.py index 6228ed0..674214c 100644 --- a/twitter_user_tweet_crawler/pool.py +++ b/twitter_user_tweet_crawler/pool.py @@ -35,8 +35,6 @@ def _on_job_complete(self, index, future): future.result() except NoSuchElementException: pass - except WebDriverException as e: - logger.error(e) # By default, `concurrent.futures` will silently log errors but will not raise them # Throw the error directly self.browser[elements].__dict__['is_using'] = False diff --git a/twitter_user_tweet_crawler/tweet.py b/twitter_user_tweet_crawler/tweet.py index 39cd213..728c92d 100644 --- a/twitter_user_tweet_crawler/tweet.py +++ b/twitter_user_tweet_crawler/tweet.py @@ -88,7 +88,11 @@ def click_sensitive_element(): result = None available_driver.get(self.link) wait = WebDriverWait(available_driver, 20) - element = wait.until(EC.presence_of_element_located((By.XPATH, '//*/time/ancestor::*[3]'))) + try: + time_stamp = available_driver.find_element(By.XPATH, '//time').get_attribute('datetime') + except: + print('老大 我是真的没time标签') + element = wait.until(EC.presence_of_element_located((By.XPATH, '//*/time/ancestor::*[5]'))) time_stamp = available_driver.find_element(By.XPATH, '//time').get_attribute('datetime') location = True try: