Open xamoko opened 4 months ago
Were u able to solve it? Having same issue here :(
@xamoko ?
@xamoko ?
Sorry for late, the detail is when load page, in that moment the page bring a cookie (that cookie is the key), after u send a request, the server return other cookie, that cookie u received not workin, so, im lookin a way to get the first cookie
async function extractHeaders(res) { const cookies = extractRelevantCookies(res) const html = await res.text() const $ = cheerio.load(html); const csrfToken = $('meta[name="csrf-token"]').attr('content')
return { "Cookie": cookies, "X-CSRF-Token": csrfToken, "Referer": BASE_URI, "Referrer-Policy": "strict-origin-when-cross-origin", 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36', 'Cache-Control': 'no-store', 'Connection': 'keep-alive' } } /** */
function extractRelevantCookies(res) {
const setCookieHeader = res.headers.get('set-cookie');
if (!setCookieHeader) {
return '';
}
const parsedCookies = parseCookies(setCookieHeader);
return _yatri_session=${parsedCookies['_yatri_session']}
;
}
function parseCookies(cookies) {
const parsedCookies = {}
cookies.split(';').map(c => c.trim()).forEach(c => {
const [name, value] = c.split('=', 2)
parsedCookies[name] = value
})
return parsedCookies
}
pilas bro.
https://github.com/jenzkupinc/REPO-JEAN-usvisa
check it out
https://github.com/jenzkupinc/REPO-JEAN-usvisa
check it out
Lo probé pero creo que en mi país me arroja un token con formato diferente, lo tengo que pasear para poder Usalo y después agregarle unos datos
Así se envían los datos y le agrega unos datos en el token con los parámetros _gat
y los recibe, agregando unos valores al final :S
@xamoko en mi pais se deben sacar dos citas una para emajada y otra para huellas en el codigo veo que esta vacia el asc_appointment intente ponerlo pero no me agendo la cita tu tienes en mente cuando son dos citas o se sacar por separado?
function checkAvailableDate return
Error: You need to sign in or sign up before continuing.
function checkAvailableDate(headers) { let yatriSession = headers["_yatri_session"] let tokenSession = headers["X-CSRF-Token"] return fetch('${BASE_URI}/schedule/${SCHEDULE_ID}/appointment/days/${FACILITY_ID}.json?appointments[expedite]=false', { "headers": Object.assign({}, { 'Cookie': yatriSession, 'X-CSRF-Token': tokenSession, "Referer": 'https://ais.usvisa-info.com/es-mx/niv', 'Referrer-Policy': 'strict-origin-when-cross-origin', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36', 'Cache-Control': 'no-store', 'Connection': 'keep-alive' }, { "Accept": "application/json", "X-Requested-With": "XMLHttpRequest", }), "cache": "no-store" }) .then(r => r.json()) .then(r => handleErrors(r)) .then(d => d.length > 0 ? d[0]['date'] : null) }