jeangnc / us-visa-bot

US Visa Bot
MIT License
144 stars 30 forks source link

checkAvailableDate #27

Open xamoko opened 4 months ago

xamoko commented 4 months ago

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) }

timucintopal commented 4 months ago

Were u able to solve it? Having same issue here :(

timucintopal commented 4 months ago

@xamoko ?

xamoko commented 4 months ago

@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

jenzkupinc commented 4 months ago

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.

jenzkupinc commented 4 months ago

https://github.com/jenzkupinc/REPO-JEAN-usvisa

check it out

xamoko commented 4 months ago

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

Captura de pantalla 2024-05-02 a la(s) 9 27 05 p m

y los recibe, agregando unos valores al final :S

Captura de pantalla 2024-05-02 a la(s) 9 28 47 p m
STK1321 commented 3 weeks ago

@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? image