Created
June 22, 2020 22:20
-
-
Save gaulatti/d52f8146244ecd0b92a9ca89d8ff6cce to your computer and use it in GitHub Desktop.
Get all Visa Appointment Wait Times in US Consulates at once
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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