Fork of the expressvpn-python library by Philippe Remy, with CLI support
Project description
ExpressVPN - Python Wrapper (LINUX) CLI Version
This fork supports cli version of Express VPN
This software is a modified version of the original developed by Philip Remy . It is adapted to work with current version of Express VPN for linux, in particular with CLI version.
Full bash documentation: https://www.expressvpn.com/support/vpn-setup/app-for-linux-cli/
This will not work on Windows!
Installation with PyPI
If the command expressvpn is already installed on your Ubuntu then just run this:
pip install expressvpn-python-cli
Download/Install the package on the official website
Refer to official site to download the official linux release: https://www.expressvpn.com/vpn-download/vpn-linux
Change your public IP every x seconds
Check the script: vpn.sh.
Set up expressvpn
You can find your activation key here: https://www.expressvpn.com/setup.
echo '[your activation code]' > activationCodeFile
expressvpnctl login activationCodeFile
You can help improve ExpressVPN by sharing anonymized diagnostic reports. Enter Y to accept or n to decline.
After login and to logout, simply run:
expressvpnctl logout
NOTE that you will have to activate expressvpn again if you log out.
NOTE To use connection commands in the CLI, either the ExpressVPN GUI client must be running, or background mode must be enabled.
Python bindings
Set Background mode enabled
Bash
expressvpnctl background enable
Python
from expressvpn_cli import background_enabled
background_enabled()
Connect
Bash
expressvpnctl connect
Python
from expressvpn_cli import connect
connect()
Connect with alias
Bash
expressvpnctl connect "[ALIAS]"
Python
from expressvpn_cli import connect_alias
connect_alias("alias")
Random connect(From the fastest servers)
Python
from expressvpn_cli import random_connect
random_connect()
Random connect(From all servers)
Python
from expressvpn_cli import random_connect
random_connect(True)
Disconnect
Bash
expressvpnctl disconnect
Python
from expressvpn_cli import disconnect
disconnect()
IP auto switching
Sometimes websites like Amazon or Google will ban you after too many requests. It's easy to detect because your script will fail for some obscure reason. Most of the time, if the HTML contains the word captcha or if the websites returns 403, it means that you probably got banned. But don't panic, you can use a VPN coupled with IP auto switching. Here's an example of a scraper doing IP auto switching:
import logging
from expressvpn_cli import *
class BannedException(Exception):
pass
def main():
background_enabled()
while True:
try:
# scrape() or any code you wish
return
except BannedException as be:
logging.info('BANNED EXCEPTION in __MAIN__')
logging.info(be)
logging.info('Lets change our PUBLIC IP GUYS!')
change_ip()
except Exception as e:
logging.error('Exception raised.')
logging.error(e)
def change_ip():
max_attempts = 10
attempts = 0
while True:
attempts += 1
try:
logging.info('GETTING NEW IP')
wrapper.random_connect()
logging.info('SUCCESS')
return
except Exception as e:
if attempts > max_attempts:
logging.error('Max attempts reached for VPN. Check its configuration.')
logging.error('Browse https://github.com/philipperemy/expressvpn-python.')
logging.error('Program will exit.')
exit(1)
logging.error(e)
logging.error('Skipping exception.')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file expressvpn_python_cli-1.0.7.tar.gz.
File metadata
- Download URL: expressvpn_python_cli-1.0.7.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
786a626f81de74b7638a5f23fc3f015cd6846bed440b941ad49472a8369b86e9
|
|
| MD5 |
e67d71b3ca2668b5552784e72a9ddc21
|
|
| BLAKE2b-256 |
90fa991f543eeeb5bd608529d5440ec25f472e3d707f2e48c1e21cf746a648f5
|
File details
Details for the file expressvpn_python_cli-1.0.7-py3-none-any.whl.
File metadata
- Download URL: expressvpn_python_cli-1.0.7-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ce5435c71f87cc2470541abf1d0538debbb2f965a2fd27cbcd02c2cad55a20b
|
|
| MD5 |
8a9f6d3942f370b80722619db478fba1
|
|
| BLAKE2b-256 |
bac507679072ababc9dddc9c6724bad6e20073cf1c3fa756d73610393c10860b
|