File size: 1,907 Bytes
4cb7ab8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import requests
from google.oauth2 import service_account
from google.auth.transport.requests import Request

# Configuration
KEY_FILE = 'indexing_key.json'
URLS = [
    "https://quicktools.dpdns.org/",
    "https://quicktools.dpdns.org/en",
    "https://quicktools.dpdns.org/de",
    "https://quicktools.dpdns.org/es",
    "https://quicktools.dpdns.org/fr",
    "https://quicktools.dpdns.org/ru",
    "https://quicktools.dpdns.org/ja",
    "https://quicktools.dpdns.org/ko",
    "https://quicktools.dpdns.org/visa-photo",
    "https://quicktools.dpdns.org/en/visa-photo",
    "https://quicktools.dpdns.org/de/visa-photo",
    "https://quicktools.dpdns.org/es/visa-photo",
    "https://quicktools.dpdns.org/fr/visa-photo",
    "https://quicktools.dpdns.org/ru/visa-photo",
    "https://quicktools.dpdns.org/ja/visa-photo",
    "https://quicktools.dpdns.org/ko/visa-photo"
]

def get_access_token():
    scopes = ['https://www.googleapis.com/auth/indexing']
    credentials = service_account.Credentials.from_service_account_file(KEY_FILE, scopes=scopes)
    credentials.refresh(Request())
    return credentials.token

def notify_indexing(url):
    token = get_access_token()
    endpoint = 'https://indexing.googleapis.com/v3/urlNotifications:publish'
    
    headers = {
        'Content-Type': 'application/json',
        'Authorization': f'Bearer {token}'
    }
    
    payload = {
        'url': url,
        'type': 'URL_UPDATED'
    }
    
    response = requests.post(endpoint, headers=headers, json=payload)
    return response.status_code, response.json()

if __name__ == '__main__':
    print(f"🚀 Starting indexing notification for {len(URLS)} URLs...")
    for url in URLS:
        status, result = notify_indexing(url)
        if status == 200:
            print(f"✅ Success: {url}")
        else:
            print(f"❌ Failed: {url} | Status: {status} | Error: {result}")