Skip to content

Commit

Permalink
chore:sleep and retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Sep 3, 2024
1 parent 0e11734 commit f5b2517
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
8 changes: 2 additions & 6 deletions updates/hotel/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from utils.tools import get_pbar_remaining, get_soup
from utils.config import config
from updates.proxy import get_proxy, get_proxy_next
from time import time, sleep
from time import time
from driver.setup import setup_driver
from utils.retry import (
retry_func,
Expand Down Expand Up @@ -58,7 +58,6 @@ def search_submit(driver, name):
)
if not submit_button:
return
sleep(1)
driver.execute_script("arguments[0].click();", submit_button)


Expand Down Expand Up @@ -141,9 +140,7 @@ def process_region_by_hotel(region):
),
)
if not page_link:
# break
continue
sleep(1)
break
driver.execute_script("arguments[0].click();", page_link)
else:
request_url = (
Expand All @@ -153,7 +150,6 @@ def process_region_by_hotel(region):
lambda: get_soup_requests(request_url, proxy=proxy),
name=f"hotel search:{name}, page:{page}",
)
sleep(1)
soup = get_soup(driver.page_source) if open_driver else page_soup
if soup:
results = (
Expand Down
8 changes: 2 additions & 6 deletions updates/multicast/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from utils.tools import get_pbar_remaining, get_soup
from utils.config import config, resource_path
from updates.proxy import get_proxy, get_proxy_next
from time import time, sleep
from time import time
from driver.setup import setup_driver
from utils.retry import (
retry_func,
Expand Down Expand Up @@ -60,7 +60,6 @@ def search_submit(driver, name):
)
if not submit_button:
return
sleep(1)
driver.execute_script("arguments[0].click();", submit_button)


Expand Down Expand Up @@ -151,9 +150,7 @@ def process_channel_by_multicast(region, type):
),
)
if not page_link:
# break
continue
sleep(1)
break
driver.execute_script("arguments[0].click();", page_link)
else:
request_url = (
Expand All @@ -163,7 +160,6 @@ def process_channel_by_multicast(region, type):
lambda: get_soup_requests(request_url, proxy=proxy),
name=f"multicast search:{name}, page:{page}",
)
sleep(1)
soup = get_soup(driver.page_source) if open_driver else page_soup
if soup:
results = (
Expand Down
5 changes: 1 addition & 4 deletions updates/online_search/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from utils.tools import check_url_by_patterns, get_pbar_remaining, get_soup
from utils.config import config
from updates.proxy import get_proxy, get_proxy_next
from time import time, sleep
from time import time
from driver.setup import setup_driver
from utils.retry import (
retry_func,
Expand Down Expand Up @@ -54,7 +54,6 @@ def search_submit(driver, name):
)
if not submit_button:
return
sleep(1)
driver.execute_script("arguments[0].click();", submit_button)


Expand Down Expand Up @@ -126,7 +125,6 @@ def process_channel_by_online_search(name):
)
if not page_link:
break
sleep(1)
driver.execute_script(
"arguments[0].click();", page_link
)
Expand All @@ -136,7 +134,6 @@ def process_channel_by_online_search(name):
lambda: get_soup_requests(request_url, proxy=proxy),
name=f"online search:{name}, page:{page}",
)
sleep(1)
soup = (
get_soup(driver.page_source) if open_driver else page_soup
)
Expand Down
2 changes: 1 addition & 1 deletion utils/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import TimeoutException

max_retries = 3
max_retries = 2
timeout = 10


Expand Down

0 comments on commit f5b2517

Please sign in to comment.