├── README.md
├── arg_parser.py
├── driver_context.py
├── main.py
└── proxies_list.txt
/README.md:
--------------------------------------------------------------------------------
1 | # Undetectable-profile-creation-Selenium
2 |
3 | How to create Undetectable profiles with API, set proxies in profiles and connect them with Selenium using Python
4 |
5 | With that code you can create profiles in Undetectable browser and use them with Selenium.
6 | With special argument you can set proxies to these profiles.
7 |
8 | You can download and try Undetectable browser for free from: https://undetectable.io
9 |
10 | We recommend to use our webdriver that you can download from link:
11 | https://undetectable.io/download/chromedriver.exe
12 | You need to save this file in folder with other files from that repository
13 |
14 | This script will create chosen amount of Undetectable profiles one by one, set proxies in profile (optional) and open https://undetectable.io in each profile.
15 | You need to install and run Undetectable browser with any paid plan that can create unlimited local profiles
16 |
17 |
How to use:
18 |
19 | 1. Install Python (you can download it from https://www.python.org/)
20 | 2. run terminal with admin rules and enter:
21 |
22 | ```
23 | pip install selenium
24 | pip install requests
25 | ```
26 |
27 | 3. download chromedriver and put it to folder with main.py
28 | 4. enter in terminal:
29 |
30 | ```
31 | python main.py [--instance AMOUNT] [--use_proxy]
32 | optional arguments:
33 | --instance AMOUNT how many profiles you want to create (default: 1)
34 | --use_proxy it will take proxy from proxies_list.txt by circle. You can add only one proxy or many proxies.
35 | script will take them one by one. (default: False)
36 |
37 | python main.py --use_proxy --instance 3 //Create 3 profiles with proxies and make things on sites
38 | ```
39 |
--------------------------------------------------------------------------------
/arg_parser.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | from dataclasses import dataclass
3 |
4 | @dataclass
5 | class InputArgParser:
6 | parser = argparse.ArgumentParser()
7 |
8 | parser.add_argument(
9 | "-p",
10 | "--use_proxy",
11 | dest="use_proxy",
12 | help="Run with proxy",
13 | default=False,
14 | action="store_true",
15 | )
16 |
17 | parser.add_argument(
18 | "-i",
19 | "--instance",
20 | dest="instance",
21 | help="Number of instance",
22 | default=1,
23 | type=int,
24 | )
25 |
26 | args = parser.parse_args()
27 | print(args)
28 |
29 | def with_proxy(self):
30 | return self.args.use_proxy
31 |
32 | def get_instance(self):
33 | return self.args.instance
34 |
--------------------------------------------------------------------------------
/driver_context.py:
--------------------------------------------------------------------------------
1 | import requests
2 | import json
3 | from selenium import webdriver
4 | from selenium.webdriver.chrome.options import Options
5 | from selenium.webdriver.chrome.service import Service
6 | from arg_parser import InputArgParser
7 | from datetime import datetime
8 |
9 | chrome_driver_path = "chromedriver.exe" # put the path to your chromedriver here
10 | ser = Service(chrome_driver_path)
11 | chrome_options = Options()
12 | port_from_settings_browser = '25325'
13 | address = "127.0.0.1"
14 | os_type = 'Windows'
15 | browser_type = 'chrome'
16 | proxies_list = []
17 | with open("proxies_list.txt", "r") as file:
18 | for line in file:
19 | proxies_list.append(line.strip())
20 | checker = 0
21 |
22 |
23 | class DriverContext:
24 | def __init__(self) -> None:
25 | global checker
26 | self.arg_parser = InputArgParser()
27 | print(
28 | self.arg_parser.get_instance(),
29 | self.arg_parser.with_proxy()
30 | )
31 |
32 | profile_name = datetime.now().strftime("%d%m%Y %H%M%S")
33 | profile_info = {'name': profile_name, 'os': os_type, 'browser': browser_type, 'notes': 'test'}
34 | if self.arg_parser.with_proxy():
35 | print("using proxy")
36 | profile_info['proxy'] = proxies_list[checker]
37 | checker = checker + 1
38 | if checker == len(proxies_list):
39 | checker = 0
40 | profile_info = json.dumps(profile_info)
41 | print('Creating profile')
42 | request = requests.post(f'http://{address}:{port_from_settings_browser}/profile/create', data=profile_info, timeout=3).json()['data']
43 | print(request)
44 | self.profile_id = request["profile_id"]
45 | print('Opening profile')
46 | request = requests.get(f'http://{address}:{port_from_settings_browser}/profile/start/{self.profile_id}', timeout=5).json()['data']
47 | debug_port = request['debug_port']
48 | chrome_options.debugger_address = f'{address}:{debug_port}'
49 |
50 | self.driver: webdriver = webdriver.Chrome(service=ser, options=chrome_options)
51 | self.driver.maximize_window()
52 |
53 | def __enter__(self) -> webdriver:
54 | print("creating a selenium agent")
55 | return self.driver
56 |
57 | def __exit__(self, exc_type, exc_val, _) -> bool:
58 | self.driver.quit()
59 | print('Closing profile')
60 | request = requests.get(f'http://{address}:{port_from_settings_browser}/profile/stop/{self.profile_id}', timeout=5).json()['data']
61 | return True
62 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | from selenium.webdriver.support.ui import WebDriverWait
2 | from arg_parser import InputArgParser
3 | from driver_context import DriverContext
4 |
5 |
6 |
7 | def execute():
8 | timeout = 10
9 | with DriverContext() as driver:
10 | WebDriverWait(driver, timeout)
11 | driver.get("https://undetectable.io")
12 |
13 | arg_parser = InputArgParser()
14 | for i in range(arg_parser.get_instance()):
15 | execute()
16 |
--------------------------------------------------------------------------------
/proxies_list.txt:
--------------------------------------------------------------------------------
1 | http://185.2.81.71:13492:14daaf0f-1243916:deebcea0b5
2 | socks5://190.2.81.74:13492:14daaf0f-1243916:deebcea0b5
3 |
--------------------------------------------------------------------------------