I am trying to use "requests" package and retrieve info from Github, like the Requests doc page explains:
import requests
r = requests.get('https://api.github.com/events')
And this:
with open(filename, 'wb') as fd:
for chunk in r.iter_content(chunk_size):
fd.write(chunk)
I have to say I don't understand the second code block.
- filename - in what form do I provide the path to the file if created? where will it be saved if not?
- 'wb' - what is this variable? (shouldn't second parameter be 'mode'?)
- following two lines probably iterate over data retrieved with request and write to the file
Python docs explanation also not helping much.
EDIT: What I am trying to do:
- use Requests to connect to an API (Github and later Facebook GraphAPI)
- retrieve data into a variable
- write this into a file (later, as I get more familiar with Python, into my local MySQL database)
openis here, where you can see what the b stands for.