I am trying to access the data on this Binance website. It is the P2P: https://p2p.binance.com/en/trade/buy/USDT.
For BUY I am using this in python3 (I am getting the data correctly for this section):
import requests
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "en-GB,en-US;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Content-Length": "123",
"content-type": "application/json",
"Host": "p2p.binance.com",
"Origin": "https://p2p.binance.com",
"Pragma": "no-cache",
"TE": "Trailers",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:88.0) Gecko/20100101 Firefox/88.0"
}
data = {
"asset": "USDT",
"fiat": "ARS",
"merchantCheck": False,
"page": 1,
"payTypes": [],
"publisherType": None,
"rows": 50,
"tradeType": "BUY"
}
r = requests.post('https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search', headers=headers, json=data)
print(r.text)
But then when I want to access this part of the page: https://p2p.binance.com/en/trade/sell/USDT (to SELL), I can't do it. Because when I change in the data the following: "tradeType": "SELL"
, it still brings me the same values of the BUY. It never brings me the SELL data.
And I am not finding out why yet.
Instead of sending requests to the website itself you can send a request to the source itself. If you check your console while the website loads results you will notice it sends a request to https://p2p.binance.com/bapi/c2c/v2/friendly/c2c/adv/search which returns an array of trade details. I believe this is what you need.