mercredi 1 avril 2020

Finding specific string and printing from collected data of a site using python

Here, i am trying to do that, i have a data from ngrok tunnel (http://127.0.0.1//api/tunnels) and i want to print only 'public_url' : 'https://.....ngrok.io' which i have collected from that site, that data looks like this

{'tunnels': [{'name': 'command_line', 'uri': '/api/tunnels/command_line', 'public_url': 'https://a28e4c77.ngrok.io', 'proto': 'https', 'config': {'addr': 'http://localhost:80', 'inspect': True}....Something more

This is the part of that data. I have use this code to collect that data.

import requests 
url = "http://127.0.0.1:4040/api/tunnels"
r = requests.get(url)
data = r.json()

I have also save this into a ngrok.txt but i have absolutely no idea to find...To write this data i use this code : -

import requests
url = "http://127.0.0.1:4040/api/tunnels"
r = requests.get(url)
data = r.json()
f = open('ngrok.txt', 'w')
f.write(data)
f.close()



Aucun commentaire:

Enregistrer un commentaire