Skip to content

Instantly share code, notes, and snippets.

@frankenstein91
Last active April 30, 2021 17:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frankenstein91/2b3662729a82048a32624d56c4bb1fbb to your computer and use it in GitHub Desktop.
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.
#! /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