Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Getting invalid argument error while passing http proxy #3379

IndrajeethY started this conversation in General
Discussion options

image

hey there i am getting this error while i try to use uc mode with proxy but it works without uc mode

import random
import sys
from seleniumbase import SB
from concurrent.futures import ThreadPoolExecutor
sys.argv.append("-n") 
def select_random_proxy(file_path):
 with open(file_path, 'r') as file:
 proxies = file.readlines()
 selected_proxy = random.choice(proxies).strip()
 parts = selected_proxy.split(':')
 user_pass = f"{parts[2]}:{parts[3]}"
 server_port = f"{parts[0]}:{parts[1]}"
 return f"{user_pass}@{server_port}"
def launch_driver(url):
 with SB(proxy=select_random_proxy('proxies.txt'), uc=True) as sb:
 sb.open(url)
 sb.wait(1)
 
urls = ['https://seleniumbase.io/demo_page' for i in range(3)]
with ThreadPoolExecutor(max_workers=len(urls)) as executor:
 for url in urls:
 executor.submit(launch_driver, url)

and this is my code

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

Set the multi_proxy arg to True to allow multiple proxies with auth at the same time:

multi_proxy=None, # Allow multiple proxies with auth when multi-threaded.

Also, post the full stack trace if you're still having issues.
You must be logged in to vote
1 reply
Comment options

oh worked, thanks. Between is there any ways to avoid timeout to avoid this, coz site sometimes takes a bit more time to load the login page after solving captcha or is there any method to send keys after solving

sb.activate_cdp_mode(self.url)
 sb.uc_gui_click_captcha()
 sb.sleep(4)
 sb.send_keys(
 "input[name='LoginForm[username]']", username, timeout=10
 )
 

2024年12月31日 19:15:39,364 - INFO - Attempt 1 failed:
Element {input[name='LoginForm[username]']} was not found after 7 seconds!
2024年12月31日 19:16:05,629 - INFO - Attempt 2 failed:
Element {input[name='LoginForm[username]']} was not found after 7 seconds!
i added timeout there still i get this error why? also is there any method to activate cdp mode only if the site is available or like refresh page?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /