How can i open a chrome profile with a proxy?

  Kiến thức lập trình

Hello i want to use python to open a specific chrome user profil but it should use a proxy.

proxies = [
    "http://username:pw@ip:port",
    "http://username:pw@ip:port"
]
chrome_profiles = [
    "C:/Users/User/AppData/Local/Google/Chrome/User Data/Profile 1",
    "C:/Users/Mimi/AppData/Local/Google/Chrome/User Data/Profile 3"
]

profile_index = on_message.counter % len(chrome_profiles)
                                profile_path = chrome_profiles[profile_index]
                                proxy = proxies[profile_index]
                                on_message.counter += 1

                                # Open the URL in Chrome with the specified profile
                                url = url.replace(")","")
                                subprocess.Popen([
                                    'C:/Program Files/Google/Chrome/Application/chrome.exe',
                                    '--user-data-dir=' + profile_path,
                                    '--proxy-server=' + proxy,
                                    url
                                ])
                                print(f"Opened link: {url} with profile: {profile_path}")

Thats my attempt, basically opening the specific chrome profile works just the connectioon is dead, like no internet at all. It has to be related to how the proxy is set.

Selenium etc are no options for my use case. I hope someone has an idea

Described above in detail with code snippets

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT