Can somebody help me? I have a telegram-bot for get p2p offers from binance. It worked good long time. But now I have a problem (2 days). I couldn't get offers for currency RUB. Output data is empty list. If I insert cookies from browser in headers, it works good. But I think this is not a good solution. Maybe I can authenticate and send request with auth data? Binance have API, but it not work with p2p
import requests as rq
import json
from pprint import pprint
from binance.spot import Spot
from binance.client import Client
client = Spot(api_key=BINANCE_API_KEY, api_secret=BINANCE_SECRET_KEY)
client2 = Client(BINANCE_API_KEY, BINANCE_SECRET_KEY)
def get_binance_data(asset='USDT', fiat='RUB', pay_types=('PostBankNew', ), trade_type='BUY', amount=1000, page=1):
data = {
"asset": asset,
"fiat": fiat,
"countries": [],
"merchantCheck": None,
"page": page,
"payTypes": list(pay_types),
"proMerchantAds": False,
"publisherType": "merchant",
"rows": 20,
"shieldMerchantAds": False,
"tradeType": trade_type,
"transAmount": amount,
}
headers = {...}
response = rq.post('https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search', json=data, headers=headers)
response2 = client.session.post('https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search', json=data)
pprint(response2.text)
pprint(response.text)
return json.loads(response.text)['data']
response
with cookie and csrf in headers return correct result with offers
response
without cookie and csrf in headers return empty list
response2
return empty list