Skip to content

Instantly share code, notes, and snippets.

@gaulatti
Created June 22, 2020 22:20
Show Gist options
  • Save gaulatti/d52f8146244ecd0b92a9ca89d8ff6cce to your computer and use it in GitHub Desktop.
Save gaulatti/d52f8146244ecd0b92a9ca89d8ff6cce to your computer and use it in GitHub Desktop.
Get all Visa Appointment Wait Times in US Consulates at once
# 1. Get into this page: https://travel.state.gov/content/travel/en/us-visas/visa-information-resources/wait-times.html
# 2. Execute the Script
# 3. Make sure all XHR requests are done
# 4. Do a console.table(items) to see the data
var items = []
var getAllData = () => {
var dataUrl = "https://travel.state.gov/content/travel/resources/database/database.getVisaWaitTimes.html";
var dataAppid = "VisaWaitTimesHomePage";
const parseString = (value, type) => {
var getNumber = parseInt(value);
var valueType = (type !== "time") ? "Calendar" : "Work";
if (!isNaN(getNumber)) {
//console.log("is a number");
if (getNumber > 1) {
return getNumber + " " + valueType + " Days";
} else {
return getNumber + " " + valueType + " Day";
}
} else {
return value;
}
}
items = []
travelStateGov.PostsVWT.sourceData.forEach(i => {
var urlString = `${dataUrl}?cid=${i.code}&aid=${dataAppid}`
jQuery.get(urlString, function (data) {
if (jQuery.trim(data.toLowerCase()) != "error") {
var vwtdata = data.split(",");
if (post == "St Petersburg") {
visitor = exchange = other = wait = "Closed"
} else {
name = i.value
code = i.code
visitor = parseString(vwtdata[0], "other").trim()
exchange = parseString(vwtdata[1], "other").trim()
other = parseString(vwtdata[2], "other").trim()
wait = parseString(vwtdata[3], "time").trim()
}
}
items.push({ name, other, visitor, exchange, wait })
});
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment