Advertisement
Shokedbrain

gosuslugi_parser_cert_python

Apr 8th, 2022
323
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 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.  
  5. def main():
  6.     gos_id = url[url.rfind('/')+1:url.find('?')]
  7.     print(gos_id)
  8.     json_url = "https://www.gosuslugi.ru/api/covid-cert-checker/v3/cert/status/" + gos_id
  9.     response = req.get(json_url)
  10.     json_text = response.text
  11.     doc = json.loads(json_text)
  12.     cert_id = doc["certId"]
  13.     expiration_date = doc["expiredAt"]
  14.     valid_from_date = doc["validFrom"]
  15.     full_name = doc["attrs"][0]['value']
  16.     birthday_date = doc["attrs"][1]['value']
  17.     passport = doc["attrs"][2]['value']
  18.     print(cert_id)
  19.     print(valid_from_date)
  20.     print(expiration_date)
  21.     print(full_name)
  22.     print(birthday_date)
  23.     print(passport)
  24.  
  25. if __name__ == "__main__":
  26.     main()
  27.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement