|
@@ -1,5 +1,5 @@
|
|
|
from selenium.webdriver.common.action_chains import ActionChains
|
|
|
-from selenium.common.exceptions import NoSuchElementException
|
|
|
+from selenium.common.exceptions import NoSuchElementException, TimeoutException
|
|
|
import random
|
|
|
import time
|
|
|
|
|
@@ -7,11 +7,15 @@ import time
|
|
|
def reply(driver, url):
|
|
|
while True:
|
|
|
reply_page_url = get_reply_page_url(driver, url)
|
|
|
- driver.get(reply_page_url)
|
|
|
- content = get_reply_content(driver)
|
|
|
- if not content == '#':
|
|
|
- if start_reply(driver, content):
|
|
|
- break
|
|
|
+ try:
|
|
|
+ driver.get(reply_page_url)
|
|
|
+ except TimeoutException:
|
|
|
+ continue
|
|
|
+ else:
|
|
|
+ content = get_reply_content(driver)
|
|
|
+ if not content == '#':
|
|
|
+ if start_reply(driver, content):
|
|
|
+ break
|
|
|
time.sleep(2)
|
|
|
|
|
|
|
|
@@ -23,7 +27,7 @@ def start_reply(driver, content):
|
|
|
return False
|
|
|
else:
|
|
|
ActionChains(driver).move_to_element(message).perform()
|
|
|
- time.sleep(3)
|
|
|
+ time.sleep(6)
|
|
|
ActionChains(driver).double_click(message).perform()
|
|
|
time.sleep(3)
|
|
|
message.send_keys(content)
|