Gevezo
Gevezo

Reputation: 363

How do I retrieve information online using python?

So this is basically the problem: I have this application that receives information and saves it using a json file, but I want to save it in a way that, if someone elses have the same app in their computer, they will receive the things I update in my own.

I think I can use Http and make some import to python, but I know nothing about http, so if theres a solution in python for this it would be better. If there's nothing in python, what do you think is the more simple way of doing it ?

Anyway, thanks ahead for those responding.

edit: That's the code, now the only problem is to upload it online.

import json
import requests
import atexit

r = requests.get('https://github.com/Gevez/gameficacao/blob/master/data-teste.json')

with open('data-teste.json','wb') as f:
    f.write(r.content)

def exit_handler():
    url = 'https://github.com/Gevez/gameficacao/blob/master/'
    contents = open('data-teste.json', 'rb').read()
    r = requests.post(url, data=contents, headers=headers)

atexit.register(exit_handler)

Upvotes: 0

Views: 223

Answers (1)

maryanne
maryanne

Reputation: 109

Check out requests. Making http requests with this library is pretty easy, if that's what you're looking to do.

Upvotes: 1

Related Questions