Advertisement
Guest User

Google Search Console API

a guest
Mar 22nd, 2022
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. from oauth2client.service_account import ServiceAccountCredentials
  2. import httplib2
  3.  
  4. SCOPES = [ "https://www.googleapis.com/auth/indexing" ]
  5. ENDPOINT = "https://indexing.googleapis.com/v3/urlNotifications:publish"
  6.  
  7. # service_account_file.json is the private key that you created for your service account.
  8. JSON_KEY_FILE = "your_login_credits.json"
  9.  
  10. credentials = ServiceAccountCredentials.from_json_keyfile_name(JSON_KEY_FILE, scopes=SCOPES)
  11.  
  12. http = credentials.authorize(httplib2.Http())
  13.  
  14. # Define contents here as a JSON string.
  15. # This example shows a simple update request.
  16. # Other types of requests are described in the next step.
  17.  
  18. content = """{
  19.  "url": "https://content-baer.de/",
  20.  "type": "URL_UPDATED"
  21. }"""
  22.  
  23. response, content = http.request(ENDPOINT, method="POST", body=content)
  24. print(response.reason)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement