May 21, 2015 11:28 AM
(This post was last modified: May 21, 2015 11:37 AM by SIM-2552982.)
So I was just experimenting with API's and Python. I made a little program where you fill in a currency and a value, it grabs the information from the API and then gives you the amount of BTC you could buy. Blockchain had a perfect API for this purpose. Now I am trying something different with OMC. I am using this API: https://omnicha.in/api/?method=getinfo
I want the program to read the OMC value, so I wrote this:
(This is just a little part of the whole code)
The problem is, that when you take a look at the API, there are a lot of other values on that page. So when they change, and my script still prints everything between characters 247 and 253, things will change their position and mess up the response.
Example: https://gyazo.com/c048e3a5facdb79799900e00dc7c3bae
or: https://gyazo.com/b26cec8e2bca4ec6a17f38c78a13e071
My question, could I use the URLLib module to print the text that's between certain characters? For example; saying it should print everything that's between omc_usd_price": and ,"market_cap". I don't know if there is some sort of method to do this, or to achieve something similar. Could you guys help me out? I am not that good at python yet
I want the program to read the OMC value, so I wrote this:
(This is just a little part of the whole code)
Code
try:
response = urlopen(request)
omc_usd1 = response.read()
omc_usd1 = omc_usd1[247:253]
print ('OMC USD Price') +(omc_usd1)+(' ')
time.sleep(59)Example: https://gyazo.com/c048e3a5facdb79799900e00dc7c3bae
or: https://gyazo.com/b26cec8e2bca4ec6a17f38c78a13e071
My question, could I use the URLLib module to print the text that's between certain characters? For example; saying it should print everything that's between omc_usd_price": and ,"market_cap". I don't know if there is some sort of method to do this, or to achieve something similar. Could you guys help me out? I am not that good at python yet


