나는 잔액이 Venmo.com인데 한 번에 3 개월 만 보여 주며 전체 거래 내역을보고 싶습니다.Chrome 개발자 도구에있는 요청을 프로그래밍 방식으로 복제하는 방법은 무엇입니까?
네트워크 개발자 탭에서 네트워크 탭 아래에서 JSON을 반환하는 https://api.venmo.com/v1/transaction-history?start_date=2017-01-01&end_date=2017-01-31
에 대한 요청을 볼 수 있습니다.
프로그래밍 방식으로 시간을 반복하고 여러 요청을하고 모든 트랜잭션을 집계하고 싶습니다. 그러나 나는 401 Unauthorized를 계속 받고있다.
초기 접근 방식은 Node.js를 사용하는 것입니다. 내가 요청의 쿠키에보고하고 secret.txt
파일로 복사 한 후 요청을 보내
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)
}
: 작동하지 않았다
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
}
}
내가 통해 모든 헤더를 복사하려고 할을 이것은 또한 작동하지 않았다.
나는 심지어 웹 사이트의 콘솔에서 요청을 시도하고 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)
을 그래서 여기 내 질문은 이것이다 : 나는 크롬 개발자 도구에서 네트워크 요청을 참조하십시오. 프로그래밍 방식으로 어떻게 동일한 요청을 할 수 있습니까? 가급적 Node.js 또는 Python에서 자동화 된 스크립트를 작성할 수 있습니다.
오. 나의. 하나님. 내가 바라는 가장 좋은 대답은 다음과 같습니다 :) – Chet