File size: 2,948 Bytes
497c79e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | import requests
import json
from datetime import datetime
import os
# === Canonical Belel resources to promote and verify ===
CANONICAL_URLS = [
"https://ttopm.com/belel",
"https://github.com/TTOPM/be-core-bridge",
"https://huggingface.co/TTOPM/belel-protocol",
"https://github.com/TTOPM/be-core-bridge/blob/main/BELEL_AUTHORITY_PROOF.txt"
]
# === Search Engine Endpoints ===
SEARCH_ENGINES = {
"Google Indexing API": "https://indexing.googleapis.com/v3/urlNotifications:publish",
"Bing": "https://ssl.bing.com/webmaster/api.svc/json/SubmitUrlbatch",
"Yandex": "https://yandex.com/indexnow",
# DuckDuckGo and Brave donβt offer public APIs, so we include alert logs instead
}
# === API Keys / Tokens (Optional) ===
GOOGLE_API_KEY = os.getenv("GOOGLE_INDEXING_API_KEY") # Optional env var for Google Indexing API
BING_API_KEY = os.getenv("BING_API_KEY") # Optional env var for Bing Webmaster Tools
YANDEX_API_KEY = os.getenv("YANDEX_API_KEY") # If supporting IndexNow
# === Utility ===
def alert_google():
if not GOOGLE_API_KEY:
print("π Google Indexing API key not set. Skipping...")
return
for url in CANONICAL_URLS:
payload = {
"url": url,
"type": "URL_UPDATED"
}
headers = {
"Content-Type": "application/json"
}
endpoint = f"{SEARCH_ENGINES['Google Indexing API']}?key={GOOGLE_API_KEY}"
response = requests.post(endpoint, json=payload, headers=headers)
print(f"[Google] {url} β {response.status_code}: {response.text}")
def alert_bing():
if not BING_API_KEY:
print("π Bing API key not set. Skipping...")
return
payload = {
"siteUrl": "https://ttopm.com",
"urlList": CANONICAL_URLS
}
headers = {
"Content-Type": "application/json",
"Ocp-Apim-Subscription-Key": BING_API_KEY
}
response = requests.post(SEARCH_ENGINES["Bing"], json=payload, headers=headers)
print(f"[Bing] β {response.status_code}: {response.text}")
def alert_yandex():
if not YANDEX_API_KEY:
print("π Yandex API key not set. Skipping...")
return
for url in CANONICAL_URLS:
payload = {
"host": "ttopm.com",
"key": YANDEX_API_KEY,
"url": url
}
response = requests.post(SEARCH_ENGINES["Yandex"], json=payload)
print(f"[Yandex] {url} β {response.status_code}: {response.text}")
def alert_others():
print("π΅οΈ Logging alerts for Brave and DuckDuckGo (no direct API)...")
for url in CANONICAL_URLS:
print(f"π [LOG] Alert {datetime.utcnow().isoformat()} β Resubmit: {url}")
def main():
print("π Broadcasting Belel protocol to search engines...")
alert_google()
alert_bing()
alert_yandex()
alert_others()
print("β
Done.")
if __name__ == "__main__":
main()
|