Skip to content

Instantly share code, notes, and snippets.

@haccer haccer/ggroup.py
Last active May 20, 2019

Embed
What would you like to do?
#!/usr/bin/env python3
# Google Groups v1
# python3 ggroup.py domains.txt
import requests
import re
import sys
with open(sys.argv[1]) as f:
sites = f.read().splitlines()
msg = ""
for site in sites:
r = requests.get("https://groups.google.com/a/"+site+"/d/")
if r.status_code == 500:
msg = "500 Error: Google Groups not found"
elif "Redirecting to" in r.text:
try:
rr = requests.get("https://accounts.google.com/AccountChooser?continue=https://groups.google.com/a/"+site+"/d/&hl=en&service=groups2&hd="+site)
if rr.status_code == 200 and "https://accounts.google.com/Service" in rr.url:
msg = "- redirect to Google"
else:
msg = "- redirect to {}".format(rr.url)
except requests.exceptions.RequestException as e:
host = re.findall(r"host='(.*?)', port", str(e))[0]
uri = re.findall(r'url: (.*?) \(Caused', str(e))[0]
msg = "- redirect to INTERNAL HOST: {}{}".format(host, uri)
elif r.status_code == 404:
msg = "- 404"
else:
msg = "- Open!"
print(site, msg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.