Skip to content

Instantly share code, notes, and snippets.

@d4rn0k
Created April 7, 2017 13:18
Show Gist options
  • Select an option

  • Save d4rn0k/cf1a5de0b5e4aac1b84e021c35ae6f78 to your computer and use it in GitHub Desktop.

Select an option

Save d4rn0k/cf1a5de0b5e4aac1b84e021c35ae6f78 to your computer and use it in GitHub Desktop.
Simple passport readiness checker
import json
import requests
import re
print("Hello I am, checking your passport!\n")
firstUrl = "https://obywatel.gov.pl/wyjazd-za-granice/sprawdz-czy-twoj-paszport-jest-gotowy"
checkUrl = "https://obywatel.gov.pl/wyjazd-za-granice/sprawdz-czy-twoj-paszport-jest-gotowy?p_p_id" \
"=Gotowoscpaszportu_WAR_Gotowoscpaszportuportlet&" \
"p_p_lifecycle=2" \
"&p_p_state=normal" \
"&p_p_mode=view&" \
"p_p_cacheability=cacheLevelPage" \
"&p_p_col_id=column-5" \
"&p_p_col_count=1"
passportID1 = "1200000010024967"
mySession = requests.Session()
mySession.headers = {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
}
firstGetResponse = mySession.get(firstUrl)
authRegex = "data-auth=\"(\w*)\""
authKey = re.search(authRegex, firstGetResponse.text, re.I | re.U)
formData = "_Gotowoscpaszportu_WAR_Gotowoscpaszportuportlet_nrSprawy=" + passportID1 \
+ "&_Gotowoscpaszportu_WAR_Gotowoscpaszportuportlet_p_auth=" + authKey.groups()[0]
response = mySession.post(checkUrl, data=formData)
print("Odpowiedź serwerka= " + response.text)
responseData = json.loads(response.text)
print(responseData[0]['status'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment