diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-06-29 03:49:42 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-06-29 03:49:42 +0900 |
| commit | e4db81206f8f572fc5355b11c20dc51b5b69ffbc (patch) | |
| tree | e9bd52769693862b4213f5a50db3138876f783da /indexnow.py | |
| parent | 34b55506fe58760262d685ad8565c1ef7f2dadf2 (diff) | |
treewide: remove unused scripts
Diffstat (limited to 'indexnow.py')
| -rw-r--r-- | indexnow.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/indexnow.py b/indexnow.py new file mode 100644 index 00000000..aa4f6b5d --- /dev/null +++ b/indexnow.py @@ -0,0 +1,34 @@ +import sys + +import requests +import validators + +if len(sys.argv) > 1: + urls = sys.argv[1:] +else: + urls = sys.stdin.read().splitlines() + +if not urls: + sys.exit(2) + +for url in urls: + if not validators.url(url): + sys.exit(3) + +host = "hakurei.app" +api_url = "https://api.indexnow.org/indexnow" + +with open("indexnow-key.txt") as keyfile: + key = keyfile.read().strip() + +def submit(urls): + print(urls) + data = { + "host": host, + "key": key, + "urlList": urls + } + r = requests.post(api_url, json=data) + print(r.status_code) + +submit(urls) |
