Guest User

Untitled

a guest
Feb 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. import requests
  2.  
  3. # Set the request parameters
  4. url = 'https://cryptohub.online/api/market/ticker/PLSR/'
  5.  
  6. # Fetch url
  7. print("Fetching url..")
  8.  
  9. # Do the HTTP get request
  10. response = requests.get(url, verify=True) #Verify is check SSL certificate
  11.  
  12. # Error handling
  13.  
  14. # Check for HTTP codes other than 200
  15. if response.status_code != 200:
  16. print('Status:', response.status_code, 'Problem with the request. Exiting.')
  17. exit()
  18.  
  19. # Decode the JSON response into a dictionary and use the data
  20.  
  21. data = response.json()
  22.  
  23. visitors = data["id"]
  24.  
  25. print('nVisitors today:'), visitors
  26.  
  27. # code ends
  28.  
  29. -=- Tried that, then tried this: -=-
  30.  
  31. import urllib
  32. import requests
  33. import json
  34.  
  35. api = 'https://cryptohub.online/api/market/ticker/PLSR/'
  36.  
  37. url = api
  38.  
  39. json_data = requests.get(url).json()
  40.  
  41. jsonList = json.load(json_data)
  42.  
  43. print (json_data[id])
  44.  
  45. -=- Tried this as well: -=-
  46.  
  47. import json
  48. import requests
  49.  
  50. url = 'https://cryptohub.online/api/market/ticker/PLSR/'
  51.  
  52. response = requests.get(url, verify=True)
  53.  
  54. data = response.json()
  55. json_data = data['quoteVolume']
  56. python_obj = json.loads(json_data)
  57. print (python_obj["id"])
  58.  
  59.  
  60. -=- If any code is incomplete, its probably because I messed with it to try and make it work. -=-
Advertisement
Add Comment
Please, Sign In to add comment