diff options
| author | Yuval Adam <_@yuv.al> | 2022-10-24 22:09:20 +0300 |
|---|---|---|
| committer | Yuval Adam <_@yuv.al> | 2022-10-24 22:09:20 +0300 |
| commit | f555f20dd5201fb186daa19080b5d6c4c7141366 (patch) | |
| tree | 983e306bd95fab06a9b6f8db3b1006ed3d7d42fe | |
| parent | 2eeb1abbe093a056e74286a9730b21957886c8a8 (diff) | |
Implement scan and update index.html
| -rw-r--r-- | scan.py | 47 | ||||
| -rw-r--r-- | templates/index.html | 19 |
2 files changed, 59 insertions, 7 deletions
@@ -7,8 +7,51 @@ ROOT_PATH = Path(__file__).parent DATA_DIR = ROOT_PATH / "data" TLDS_URL = "https://data.iana.org/TLD/tlds-alpha-by-domain.txt" +MALE_NAMES_URL = "https://raw.githubusercontent.com/DictionaryHouse/EnglishName/master/top_1000_EN_%E7%94%B7%E6%80%A7names_english.txt" +FEMALE_NAMES_URL = "https://raw.githubusercontent.com/DictionaryHouse/EnglishName/master/top_1000_EN_%E5%A5%B3%E6%80%A7names_english.txt" with open(DATA_DIR / "tlds.txt", "w") as f: + print("Fetching TLDs...") res = requests.get(TLDS_URL) - tlds = [tld.lower() for tld in res.text.split("\n")[1:] if len(tld) < 4] - f.write("\n".join(tlds).strip())
\ No newline at end of file + tlds = [tld.lower() for tld in res.text.strip().split("\n")[1:] if len(tld) < 4] + f.write("\n".join(tlds).strip()) + TLDS = set(tlds) + +NAMES = [] + +with open(DATA_DIR / "names.txt", "w") as f: + print("Fetching female names...") + res = requests.get(FEMALE_NAMES_URL) + f.write(res.text) + NAMES += res.text.split("\n") + print("Fetching male names...") + res = requests.get(MALE_NAMES_URL) + f.write(res.text) + NAMES += res.text.split("\n") + +# print(NAMES) +# print(TLDS) + +CANDIDATES = [] + +for name in NAMES: + if name[-2:] in TLDS: + CANDIDATES.append(f"{name[:-2]}.{name[-2:]}") + if name[-3:] in TLDS: + CANDIDATES.append(f"{name[:-3]}.{name[-3:]}") + +with open(DATA_DIR / "domains.txt", "w") as f: + f.write("\n".join(CANDIDATES).strip()) + +for c in CANDIDATES: + try: + print(f"Fetching {c}...", end="") + res = requests.get(f"http://{c}", timeout=5) + if res.ok: + print(f"Found {c}!") + with open(DATA_DIR / "homepages" / f"{c}.html", "w") as f: + f.write(res.text) + else: + print("x") + except: + print("x")
\ No newline at end of file diff --git a/templates/index.html b/templates/index.html index a740c34..344f50c 100644 --- a/templates/index.html +++ b/templates/index.html @@ -18,9 +18,18 @@ <link href="base.css" rel="stylesheet"> </head> - <body> - {% for name in names %} - <a href="{{ name.domain }}">{{name.name}} - {{name.domain}}</a> - {% endfor %} + <body class="code mw7-ns ph3 center"> + <h1>Domain Name Hack Club</h1> + <p>An exclusive club of nerds that own the <a href="https://en.wikipedia.org/wiki/Domain_hack" class="link">domain hack</a> to their name, and serve their personal homepage from it.</p> + + <ul> + {% for name in names %} + <li><a href="https://{{ name.domain }}">{{ name.name }}</li> + {% endfor %} + </ul> + <hr> + <footer> + Created by <a href="https://yuv.al">Yuval Adam</a>. Maintained collaboratively on <a href="https://github.com/yuvadm/namehack.club">Github</a>. + </footer> </body> -</html> +</html>
\ No newline at end of file |
