Last active
April 30, 2021 17:36
-
-
Save frankenstein91/2b3662729a82048a32624d56c4bb1fbb to your computer and use it in GitHub Desktop.
I wrote this little tool to check websites for Google FLOC. I hope I have understood Google's description of the server opt-out correctly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/env python | |
import argparse, multiprocessing, urllib.request,validators | |
if __name__ == '__main__': | |
multiprocessing.freeze_support() | |
argsParser = argparse.ArgumentParser() | |
argsParser.add_argument("-u","--url",help="the url of the website",default="https://www.github.com",type=str) | |
args = argsParser.parse_args() | |
print("testing: " + args.url) | |
if validators.url(args.url): | |
print("valid URL") | |
response = urllib.request.urlopen(urllib.request.Request(args.url,headers={"User-Agent":""})) | |
PermissionsPolicyHeader = response.getheader('Permissions-Policy') | |
if PermissionsPolicyHeader: | |
if "interest-cohort=()" in PermissionsPolicyHeader: | |
print("this website does not use FLOC") | |
else: | |
print("this website maybe use FLOC") | |
if "geolocation=()" in PermissionsPolicyHeader: | |
print("this website does not use geolocation") | |
else: | |
print("this website maybe use geolocation") | |
else: | |
print("this website maybe use FLOC and geolocation") | |
else: | |
print("not an URL") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment