Created
July 18, 2020 00:53
-
-
Save umihico/e275f1a2963b8387075279fe5cb92424 to your computer and use it in GitHub Desktop.
Download all user's profile pictures in your Slack workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import time | |
TOKEN = "xoxb-12345678-12345679-thairoo1airi6om7Ahga" | |
def main(): | |
url = "https://slack.com/api/users.list?token=" + TOKEN | |
response = requests.get(url) | |
response.raise_for_status() | |
for i, member in enumerate(response.json()['members']): | |
image512px_url = member['profile']['image_512'] | |
print(i + 1, image512px_url) | |
response = requests.get(image512px_url) | |
response.raise_for_status() | |
filename = f"./{member['team_id']}-{member['id']}-{member['name']}.jpg" | |
with open(filename, 'wb') as f: | |
f.write(response.content) | |
time.sleep(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment