Advertisement
Shokedbrain

gosuslugi_parser_cert_python1

Apr 18th, 2022
307
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.05 KB | None | 0 0
  1. import requests as req
  2. import json
  3. url = "https://www.gosuslugi.ru/covid-cert/status/14d22f26-9cf2-4437-addd-51f155c63f72?lang=ru"
  4. #url = "https://www.gosuslugi.ru/covid-cert/verify/7000000025591744?lang=ru&ck=ceb553b6ad74f2dd1e9e78e84401e13e"
  5.  
  6.  
  7. def main():
  8.     gos_id = url[url.rfind('/')+1:url.find('?')]
  9.     print(gos_id)
  10.     json_url = "https://www.gosuslugi.ru/api/covid-cert-checker/v3/cert/status/" + gos_id
  11.     response = req.get(json_url)
  12.     if response.status_code == 400:
  13.         print("error")
  14.     else:
  15.         json_text = response.text
  16.         doc = json.loads(json_text)
  17.         cert_id = doc["certId"]
  18.         expiration_date = doc["expiredAt"]
  19.         valid_from_date = doc["validFrom"]
  20.         full_name = doc["attrs"][0]['value']
  21.         birthday_date = doc["attrs"][1]['value']
  22.         passport = doc["attrs"][2]['value']
  23.         print(cert_id)
  24.         print(valid_from_date)
  25.         print(expiration_date)
  26.         print(full_name)
  27.         print(birthday_date)
  28.         print(passport)
  29.  
  30.  
  31. if __name__ == "__main__":
  32.     main()
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement