hakurei.app/indexnow.py
Ophestra e4db81206f
All checks were successful
Static / Flake checks (push) Successful in 21s
Static / Create distribution (push) Successful in 41s
treewide: remove unused scripts
2025-06-29 03:49:42 +09:00

35 lines
585 B
Python

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)