Saturday, June 22, 2024
HomePythonLearn how to Run Windscribe VPN in Home windows with Python

Learn how to Run Windscribe VPN in Home windows with Python

On this tutorial, we’ll present you the best way to run Windscribe VPN in Home windows utilizing Python Code. Windscribe is a well-liked VPN service that provides a number of options. Windscribe’s free model maintains the identical velocity because the paid plans.

The next code is a Python script that interacts with the Windscribe VPN shopper utilizing its command-line interface (CLI) to carry out connection and disconnection actions.

import os

def windscribe(motion, location=None):
    windscribe_cli_path = r"C:Program RecordsdataWindscribewindscribe-cli.exe"
    if location is None:
        command = f'"{windscribe_cli_path}" {motion}'
        command = f'"{windscribe_cli_path}" {motion} {location}'

# Join
windscribe("join", "US Central")

# Disconnect

Be sure that the os module is put in. The os module is a regular Python library that gives a approach to work together with the working system, together with operating system instructions. The windscribe_cli_path variable is ready to the file path of the Windscribe CLI executable. Change this file path if the file location of CLI in your system is totally different.

We now have set the placement “US Central”. It will end result within the Windscribe VPN shopper connecting to a server situated within the US Central area. You may select any location you need based mostly on the placement Windscribe helps.

Learn how to Randomly Hook up with VPN Places

The next code provides extra performance to the earlier script. It randomizes the collection of VPN server areas and likewise logs the actions and outcomes right into a log file.

# Randomly choose location
import os
import random
from datetime import datetime

def windscribe_random(motion, connect_list=None):
    # Join
    windscribe_cli_path = r"C:Program RecordsdataWindscribewindscribe-cli.exe"    
    if connect_list shouldn't be None:
        location = random.alternative(connect_list)        
        output = os.popen(f'"{windscribe_cli_path}" {motion} {location}').learn()
        # Write Log
        log = a part of(os.getcwd(), "windscribe-log.txt")
        log_datetime = f"{ %H:%M:%S} {output}"
        log_datetime2 = "n".be a part of(["", log_datetime])
        if os.path.isfile(log):
            with open(log, "a") as f:
            with open(log, "w") as f:
        os.popen(f'"{windscribe_cli_path}" {motion}')

# Join
connect_list = ["US Central", "US East", "US West", "Canada East", "Canada West"]
windscribe_random("join", connect_list)

# Disconnect

The above code randomly selects a location from the listing [“US Central”, “US East”, “US West”, “Canada East”, “Canada West”]

The script creates information in a log file that embody the present date and time from and appends the command output. It then checks if a log file named “windscribe-log.txt” exists within the present working listing. If the file exists, the log entry is appended to it. If not, a brand new log file is created.

Associated Posts

Prime 50 Python Tutorials



Please enter your comment!
Please enter your name here

Most Popular

Recent Comments