├── README.md └── script.py /README.md: -------------------------------------------------------------------------------- 1 | # undetectable-selenium-connection 2 | 3 | How to start Undetectable profiles with API and connect them with Selenium using Python 4 | 5 | With that code you can use Selenium with Undetectable browser profiles. 6 | 7 | You can download app and try for free from: [Undetectable Browser](https://go.undetectable.io/gh) 8 | 9 | We recommend to use our webdriver that you can download from link: 10 | https://undetectable.io/download/chromedriver.exe 11 | You need to save this file in folder with script.py. 12 | 13 | This script will start Undetectable profiles that stored in folder "test" one by one and open few sites in these profiles. 14 | 15 |

How to use:

16 | 17 | 1. Install Python (you can download it from https://www.python.org/) 18 | 2. run terminal with admin rules and enter: 19 | 20 | ``` 21 | pip install selenium 22 | pip install requests 23 | ``` 24 | 25 | 3. download chromedriver and put it to folder with script.py 26 | 4. open Undetectable browser, create few profiles and choose folder with name "test" for them 27 | 5. enter in terminal: 28 | 29 | ``` 30 | python script.py 31 | ``` 32 | -------------------------------------------------------------------------------- /script.py: -------------------------------------------------------------------------------- 1 | from time import sleep 2 | import requests 3 | from selenium import webdriver 4 | from selenium.webdriver.chrome.options import Options 5 | from selenium.webdriver.chrome.service import Service 6 | 7 | address = "127.0.0.1" # Local API IP address (if you work from another PC on the same network or a port is open in the router settings, you can access the local API remotely and this address will need to be changed) 8 | port_from_settings_browser = '25325' # Local API port (can be found in the program settings) 9 | chrome_driver_path = "chromedriver.exe" # Path to chromedriver for v110 10 | ser = Service(chrome_driver_path) 11 | chrome_options = Options() 12 | list_response = requests.get(f'http://{address}:{port_from_settings_browser}/list').json()['data'] # Send a request to the local API to get a list of profiles 13 | profile_id = '' 14 | 15 | for key, value in list_response.items(): # Loop through the list of profiles and run them one by one 16 | if value['folder'] == 'test': # Here you can add a check to run only the profiles you need (in this example, we run the profiles that are in the 'test' folder) 17 | profile_id = key 18 | if value['status'] == 'Available': # If the profile is not running, then run the profile and take the debug_port 19 | start_profile_response = requests.get(f'http://{address}:{port_from_settings_browser}/profile/start/{profile_id}', timeout=5).json()['data'] 20 | debug_port = start_profile_response['debug_port'] 21 | if value['status'] == 'Started': # If the profile is running, then we simply take the debug_port from the available data 22 | debug_port = value['debug_port'] 23 | if value['status'] == 'Locked': # If the profile is Locked, then skip 24 | continue 25 | if debug_port: # We check if the browser has a connection port (WebEngine profiles doesnt have ports, so we close them immediately) 26 | chrome_options.debugger_address = f'{address}:{debug_port}' 27 | driver = webdriver.Chrome(service=ser, options=chrome_options) 28 | driver.get("https://whoer.net/") # Open whoer.net in active tab 29 | driver.switch_to.new_window('tab') # Create a new tab and switch to it 30 | driver.get(url='https://browserleaks.com/js') # Open browserleaks.com/js in active tab 31 | # You can add any other actions here 32 | sleep(5) # Wait 5 sec 33 | requests.get(f'http://{address}:{port_from_settings_browser}/profile/stop/{profile_id}') # Stop profile 34 | --------------------------------------------------------------------------------