Changed login order to accommodate 2fa, added prompt, change language on ratelimit waiting
This commit is contained in:
@@ -20,7 +20,7 @@ class Progress:
|
|||||||
if no_tweets_limit:
|
if no_tweets_limit:
|
||||||
if waiting:
|
if waiting:
|
||||||
sys.stdout.write(
|
sys.stdout.write(
|
||||||
"\rTweets scraped : {} - waiting to access older tweets {} min on 15 min".format(
|
"\rTweets scraped : {} - Rate Limited: waiting to access older tweets. Attempt to proceed {} over 15 min".format(
|
||||||
current, retry_cnt
|
current, retry_cnt
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -212,8 +212,8 @@ class Twitter_Scraper:
|
|||||||
sleep(3)
|
sleep(3)
|
||||||
|
|
||||||
self._input_username()
|
self._input_username()
|
||||||
self._input_unusual_activity()
|
|
||||||
self._input_password()
|
self._input_password()
|
||||||
|
self._input_unusual_activity()
|
||||||
|
|
||||||
cookies = self.driver.get_cookies()
|
cookies = self.driver.get_cookies()
|
||||||
|
|
||||||
@@ -283,14 +283,16 @@ It may be due to the following:
|
|||||||
unusual_activity = self.driver.find_element(
|
unusual_activity = self.driver.find_element(
|
||||||
"xpath", "//input[@data-testid='ocfEnterTextTextInput']"
|
"xpath", "//input[@data-testid='ocfEnterTextTextInput']"
|
||||||
)
|
)
|
||||||
unusual_activity.send_keys(self.username)
|
# Prompt for 2FA code input
|
||||||
|
two_fa_code = input("Enter 2FA code: ").strip()
|
||||||
|
unusual_activity.send_keys(two_fa_code)
|
||||||
unusual_activity.send_keys(Keys.RETURN)
|
unusual_activity.send_keys(Keys.RETURN)
|
||||||
sleep(3)
|
sleep(3)
|
||||||
break
|
break
|
||||||
except NoSuchElementException:
|
except NoSuchElementException:
|
||||||
input_attempt += 1
|
input_attempt += 1
|
||||||
if input_attempt >= 3:
|
if input_attempt >= 3:
|
||||||
break
|
break
|
||||||
|
|
||||||
def _input_password(self):
|
def _input_password(self):
|
||||||
input_attempt = 0
|
input_attempt = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user