diff options
| author | Daniel Micay <daniel.micay@grapheneos.org> | 2024-05-12 11:18:51 -0400 |
|---|---|---|
| committer | GrapheneOS <contact@grapheneos.org> | 2024-05-12 11:42:26 -0400 |
| commit | 79f9218c3405af4771638ae943af265dff05358a (patch) | |
| tree | 01ced19ca61bd3b895ed6666b905916cf34bf1ab /indexnow | |
| parent | 19f8de4fabbf9e5a6f54a96cef935d43016a3268 (diff) | |
add IndexNow script
Diffstat (limited to 'indexnow')
| -rwxr-xr-x | indexnow | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/indexnow b/indexnow new file mode 100755 index 00000000..dcb9942a --- /dev/null +++ b/indexnow @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +import sys + +import requests +import validators + +if len(sys.argv) > 1: + urls = sys.argv[1:] +else: + urls = sys.stdin.read().splitlines() + +for url in urls: + if not validators.url(url): + sys.exit(2) + +if not urls: + sys.exit(3) + +host = "grapheneos.org" +api_url = "https://api.indexnow.org/indexnow" + +with open("indexnow-key.txt") as keyfile: + key = keyfile.read().strip() + +def submit(urls): + data = { + "host": host, + "key": key, + "urlList": urls + } + r = requests.post(api_url, json=data) + print(r.status_code) + +submit(urls) |
