AdAway-py is a python 3 script to block ads using the system host file. It works in Linux
In GNU/Linux distros exist a file in /etc/hosts (a.k.a. host file that contains domain names associated to an IP. This applies to Windows too, but the file is in a different location. This is a method to resolve hostnames without using Adaway-py download files that contains the hostnames of publicity servers and associate them with an non-existant IP
- Can block publicity domains or any other
- You don't need to load ads, so the navigation speed increases
- It doesn't require additional software
- It works in all the system, not only in the web browser
- Clone this repository using git
git clone https://github.com/edieguez/adaway-py.git- Download it as a zip file
- Download a compressed version this is the recommended way if you only want to use the script
Just enter in the script directory and type
sudo ./__main__.pyyou can execute it from the outside folder with
sudo python adaway-pyor if you use the compressed file
sudo ./adaway.pyYou can use some flags to do specific actions
usage: adaway.py [-h] [-o HOSTS_FILE] [-a | -d | -w host [host ...] | -b host [host ...]]
A python3 script to block ads using the hosts file
options:
-h, --help show this help message and exit
-o HOSTS_FILE output file
-a apply blocking
-d deactivate blocking
-w host [host ...] whitelist one or multiple hosts
-b host [host ...] blacklist one or multiple hostsThe configuration file is generated in the first run and it looks like this
{
"blacklist": [
"www.nsa.gov",
"somenastydomain.com"
],
"custom_hosts": {
"mydomain.com": "127.0.0.1",
"itanimulli.com": "50.63.202.25"
},
"host_files": [
"http://adaway.org/hosts.txt",
"http://hosts-file.net/ad_servers.asp",
"http://winhelp2002.mvps.org/hosts.txt",
"http://someonewhocares.org/hosts/hosts"
],
"whitelist": [
"adf.ly",
"www.linkbucks.com"
]
}It contains only four sections
A list of domains that the script will block. It allows you to include hosts that are not in the hosts files
A dictionary that allows you to personalize your own hosts
Contains all the source files to block ad domains
A list of domains that the script won't block even if they are in one of the host files

