Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added poa embassy and pt-br support #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
config.ini
21 changes: 11 additions & 10 deletions embassy.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Embassy List
Embassies = {
# [EMBASSY (COUNTRY CODE), FACILITY_ID (EMBASSY ID), "Continue in different languages"],
"en-am-yer": ["en-am", 122, "Continue"], # English - Armenia - YEREVAN
"es-co-bog": ["es-co", 25, "Continuar"], # Spanish - Colombia - Bogotá
"en-ca-cal": ["en-ca", 89, "Continue"], # English - Canada - Calgary
"en-ca-hal": ["en-ca", 90, "Continue"], # English - Canada - Halifax
"en-ca-mon": ["en-ca", 91, "Continue"], # English - Canada - Montreal
"en-ca-ott": ["en-ca", 92, "Continue"], # English - Canada - Ottawa
"en-ca-que": ["en-ca", 93, "Continue"], # English - Canada - Quebec City
"en-ca-tor": ["en-ca", 94, "Continue"], # English - Canada - Toronto
"en-ca-van": ["en-ca", 95, "Continue"], # English - Canada - Vancouver
# [EMBASSY (COUNTRY CODE), FACILITY_ID (EMBASSY ID), "Continue in different languages", "Success reschedule message in page", "Error reschedule message in page"],
"pt-br-poa": ["pt-br", 128, "Continuar", "Você agendou com êxito sua nomeação de visto", "Seu agendamento não pode ser realizado. Por favor, selecione uma opção válida."], # Portuguese - Brazil - Porto Alegre
"en-am-yer": ["en-am", 122, "Continue", "Successfully Scheduled", ""], # English - Armenia - YEREVAN
"es-co-bog": ["es-co", 25, "Continuar", "Successfully Scheduled", ""], # Spanish - Colombia - Bogotá
"en-ca-cal": ["en-ca", 89, "Continue", "Successfully Scheduled", ""], # English - Canada - Calgary
"en-ca-hal": ["en-ca", 90, "Continue", "Successfully Scheduled", ""], # English - Canada - Halifax
"en-ca-mon": ["en-ca", 91, "Continue", "Successfully Scheduled", ""], # English - Canada - Montreal
"en-ca-ott": ["en-ca", 92, "Continue", "Successfully Scheduled", ""], # English - Canada - Ottawa
"en-ca-que": ["en-ca", 93, "Continue", "Successfully Scheduled", ""], # English - Canada - Quebec City
"en-ca-tor": ["en-ca", 94, "Continue", "Successfully Scheduled", ""], # English - Canada - Toronto
"en-ca-van": ["en-ca", 95, "Continue", "Successfully Scheduled", ""], # English - Canada - Vancouver
}
21 changes: 15 additions & 6 deletions visa.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
EMBASSY = Embassies[YOUR_EMBASSY][0]
FACILITY_ID = Embassies[YOUR_EMBASSY][1]
REGEX_CONTINUE = Embassies[YOUR_EMBASSY][2]
SUCCESS_RESCHEDULE_MESSAGE = Embassies[YOUR_EMBASSY][3]
ERROR_RESCHEDULE_MESSAGE = Embassies[YOUR_EMBASSY][4]

# Notification:
# Get email notifications via https://sendgrid.com/ (Optional)
Expand Down Expand Up @@ -152,11 +154,15 @@ def start_process():
auto_action("Privacy", "class", "icheckbox", "click", "", STEP_TIME)
auto_action("Enter Panel", "name", "commit", "click", "", STEP_TIME)
Wait(driver, 60).until(EC.presence_of_element_located((By.XPATH, "//a[contains(text(), '" + REGEX_CONTINUE + "')]")))
# Continue to reschedule page
driver.get(APPOINTMENT_URL)
Wait(driver, 60).until(EC.presence_of_element_located((By.NAME, "commit")))
auto_action("Continue to reschedule page", "name", "commit", "click", "", STEP_TIME)
Wait(driver, 60).until(EC.presence_of_element_located((By.ID, "appointments_submit")))
print("\n\tlogin successful!\n")

def reschedule(date):
time = get_time(date)
driver.get(APPOINTMENT_URL)
headers = {
"User-Agent": driver.execute_script("return navigator.userAgent;"),
"Referer": APPOINTMENT_URL,
Expand All @@ -172,12 +178,15 @@ def reschedule(date):
"appointments[consulate_appointment][time]": time,
}
r = requests.post(APPOINTMENT_URL, headers=headers, data=data)
if(r.text.find('Successfully Scheduled') != -1):
if(r.text.find(SUCCESS_RESCHEDULE_MESSAGE) != -1):
title = "SUCCESS"
msg = f"Rescheduled Successfully! {date} {time}"
else:
title = "FAIL"
msg = f"Reschedule Failed!!! {date} {time}"
if (r.text.find(ERROR_RESCHEDULE_MESSAGE)):
msg = f"Reschedule Failed!!! {date} {time} \n Seu agendamento não pode ser realizado. Por favor, selecione uma opção válida."
else:
msg = f"Reschedule Failed!!! {date} {time} \n {r.text}"
return [title, msg]


Expand Down Expand Up @@ -210,7 +219,7 @@ def get_available_date(dates):
# Evaluation of different available dates
def is_in_period(date, PSD, PED):
new_date = datetime.strptime(date, "%Y-%m-%d")
result = ( PED > new_date and new_date > PSD )
result = ( PED >= new_date and new_date >= PSD )
# print(f'{new_date.date()} : {result}', end=", ")
return result

Expand Down Expand Up @@ -290,9 +299,9 @@ def info_logger(file_path, log):
print(msg)
info_logger(LOG_FILE_NAME, msg)
time.sleep(RETRY_WAIT_TIME)
except:
except Exception as e:
# Exception Occured
msg = f"Break the loop after exception!\n"
msg = f"Break the loop after exception!\n {e}"
END_MSG_TITLE = "EXCEPTION"
break

Expand Down