kboghe / NordVPN-switcher

Rotate between different NordVPN servers with ease. Works both on Linux and Windows without any required changes to your code!
https://pypi.org/project/nordvpn-switcher/
189 stars 51 forks source link

Question on how to use it #19

Closed trihardseven closed 3 years ago

trihardseven commented 3 years ago

I don't really now how to program and all this python stuff, but following the tutorial I was able to get to this part cmd_O8ZBjY4myi But It's not working, probably because I'm doing everything wrong. What I need is a way to change servers every 10 minutes, preferably in the americas. Can someone help me out?

kboghe commented 3 years ago

Hi there,

Don't worry, let's see what I can do for you. Here's my suggestion using only notepad and the Windows command prompt:

First: have you installed nordvpn-switcher properly? Open your command prompt and type

python -m pip install nordvpn-switcher

If the installation was successful, you're good to go! So:

==> open notepad

==> paste the following code:

import time
from bs4 import BeautifulSoup
import requests
import json
from nordvpn_switcher import initialize_VPN,rotate_VPN,terminate_VPN

serverlist =  BeautifulSoup(requests.get("https://nordvpn.com/api/server").content,"html.parser")
site_json=json.loads(serverlist.text)

filtered_servers = {key: [] for key in ['windows_names','linux_names']}
for specific_dict in site_json:
    try:
        if specific_dict['categories'][0]['name'] == 'Standard VPN servers':
            filtered_servers['windows_names'].append(specific_dict['name'])
            filtered_servers['linux_names'].append(specific_dict['domain'].split('.')[0])
    except IndexError:
        pass

servers_us = [x for x in filtered_servers['windows_names'] if 'United States' in x]

initialize_VPN(save=1,area_input=servers_us)
time.sleep(8)
for i in range(3):
    rotate_VPN()
    time.sleep(60 * 10)

This will basically fetch a list of all NordVPN us servers, saving it in a list (called 'servers_us'), and it will rotate between those servers at random every ten minutes (time.sleep(60 * 10)). If you want to change the time interval, just change the 10 to...well, whatever you like!

==> Save this file as 'rotate_servers.py' in your work directory (Looks like it's users/Rance here)

==> type the following in your command prompt:

python rotate_servers.py

That should do the trick! Please let me know whether this has solved your issue or not.

trihardseven commented 3 years ago

Thank you very much, that worked perfectly