From a2d657da7834b9a673b07427f1acf773356fe2f1 Mon Sep 17 00:00:00 2001 From: kaesinol Date: Sun, 12 Nov 2023 22:27:15 +0800 Subject: [PATCH] fuck u twitter --- tests/CI.py | 4 ++-- twitter_user_tweet_crawler/tweet.py | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/CI.py b/tests/CI.py index 46fbade..71c2e81 100644 --- a/tests/CI.py +++ b/tests/CI.py @@ -19,9 +19,9 @@ def get_browser() -> WebDriver: class TestCase(unittest.TestCase): def test_spider(self): broswer = get_browser() - tweet = Tweet('https://twitter.com/jack/status/20', is_ci_test=True) + tweet = Tweet('https://twitter.com/_CASTSTATION/status/1697029186777706544', is_ci_test=True) tweet.load_data(broswer) - self.assertEqual(tweet.text, 'just setting up my twttr') # add assertion here + self.assertEqual(tweet.text, 'miku miku oo ee oo') # add assertion here if __name__ == '__main__': diff --git a/twitter_user_tweet_crawler/tweet.py b/twitter_user_tweet_crawler/tweet.py index 728c92d..3ed5c40 100644 --- a/twitter_user_tweet_crawler/tweet.py +++ b/twitter_user_tweet_crawler/tweet.py @@ -88,10 +88,6 @@ def click_sensitive_element(): result = None available_driver.get(self.link) wait = WebDriverWait(available_driver, 20) - 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