Iterating over 100 user ids

for i in range(100):
url=“http://graph.facebook.com/i/picture?type=large
r=requests.get(url)
with open(“sample.jpg”, ‘wb’) as f:
f.write(r.content)

this ain’t working

import requests

for i in range(100):
url=“http://graph.facebook.com/"+str(i)+"/picture?type=large
r=requests.get(url)
with open(‘sample.jpeg’, ‘wb’) as f:
f.write(r.content)

This would run, but remember the url may be incorrect for some of the values of integer and you may not receive image for some of them, but for rest it will produce correct images.

Hope this cleared your doubt. :blush:

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like