Estoy viendo mi saldo en Venmo.com , pero solo te muestran 3 meses a la vez y me gustaría obtener mi historial de transacciones completo.
Mirando las Herramientas para desarrolladores de Chrome, en la pestaña de red, puedo ver la solicitud a https://api.venmo.com/v1/transaction-history?start_date=2017-01-01&end_date=2017-01-31 que devuelve JSON .
Me gustaría iterar programáticamente a través del tiempo y hacer varias solicitudes y agregar todas las transacciones. Sin embargo, sigo recibiendo 401 no autorizado.
Mi enfoque inicial fue simplemente usar Node.js. Miré la cookie en la solicitud y la copié en un archivo secret.txt y luego envié la solicitud:
import fetch from 'node-fetch' import fs from 'fs-promise' async function main() { try { const cookie = await fs.readFile('secret.txt') const options = { headers: { 'Cookie': cookie, }, } try { const response = await fetch('https://api.venmo.com/v1/transaction-history?start_date=2016-11-08&end_date=2017-02-08', options) console.log(response) } catch(e) { console.error(e) } } catch(e) { console.error('please put your cookie in a file called `secret.txt`') return } }Eso no funcionó. Intenté copiar todos los encabezados:
const cookie = await fs.readFile('secret.txt') const options = { headers: { 'Accept-Encoding': 'gzip, deflate, sdch, br', 'Accept-Language': 'en-US,en;q=0.8', 'Cache-Control': 'no-cache', 'Connection': 'keep-alive', 'Cookie': cookie, 'Host': 'api.venmo.com', 'Origin': 'https://venmo.com', 'Pragma': 'no-cache', 'Referer': 'https://venmo.com/account/settings/balance/statement?end=02-08-2017&start=11-08-2016', 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36', }, } try { const response = await fetch('https://api.venmo.com/v1/transaction-history?start_date=2016-11-08&end_date=2017-02-08', options) console.log(response) } catch(e) { console.error(e) }Esto tampoco funcionó.
Incluso intenté hacer la solicitud desde la consola del sitio web y obtuve un 401:
fetch('https://api.venmo.com/v1/transaction-history?start_date=2016-11-08&end_date=2017-02-08', {credentials: 'same-origin'}).then(console.log)Así que mi pregunta aquí es la siguiente: Veo una solicitud de red en las herramientas para desarrolladores de Chrome. ¿Cómo puedo hacer esa misma solicitud programáticamente? Preferiblemente en Node.js o Python para poder escribir un script automatizado.
En la pestaña Red de las Herramientas para desarrolladores de Chrome, haga clic con el botón derecho en la solicitud y haga clic en "Copiar" > "Copiar como cURL (bash)". Luego, puede escribir un script usando el comando curl directamente o usar https://curlconverter.com/ para convertir el comando cURL a Python, JavaScript, PHP, R, Go, Rust, Elixir, Java, MATLAB, Dart o JSON. .