Last active
May 7, 2023 06:30
-
-
Save judell/fc50a0eb14017adb78249c941556758a to your computer and use it in GitHub Desktop.
masto-test.py
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
from mastodon import Mastodon #You need to install mastodonpy for python3. | |
import os | |
import logging | |
logging.basicConfig(level=logging.DEBUG) | |
mastodon = Mastodon( | |
access_token='***', | |
api_base_url='https://social.coop' | |
#access_token='***', | |
#api_base_url='https://mastodon.social' | |
) | |
toots = [] | |
max_id = None | |
while len(toots) < 100: | |
batch = mastodon.timeline_home(limit=40, max_id=max_id) | |
if not batch: | |
break | |
toots += batch | |
max_id = batch[-1]['id'] | |
toots = toots[:100] | |
print (len(toots)) | |
""" | |
debug trace for mastodon.social | |
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): mastodon.social:443 | |
DEBUG:urllib3.connectionpool:https://mastodon.social:443 "GET /api/v1/instance/ HTTP/1.1" 200 3767 | |
DEBUG:urllib3.connectionpool:https://mastodon.social:443 "GET /api/v1/timelines/home?limit=40 HTTP/1.1" 200 265586 | |
DEBUG:urllib3.connectionpool:https://mastodon.social:443 "GET /api/v1/timelines/home?max_id=110325817429687442&limit=40 HTTP/1.1" 200 255994 | |
DEBUG:urllib3.connectionpool:https://mastodon.social:443 "GET /api/v1/timelines/home?max_id=110325703268829194&limit=40 HTTP/1.1" 200 265322 | |
100 | |
""" | |
""" | |
debug trace for social.coop | |
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): social.coop:443 | |
DEBUG:urllib3.connectionpool:https://social.coop:443 "GET /api/v1/instance/ HTTP/1.1" 200 None | |
DEBUG:urllib3.connectionpool:https://social.coop:443 "GET /api/v1/timelines/home?limit=40 HTTP/1.1" 200 None | |
DEBUG:urllib3.connectionpool:https://social.coop:443 "GET /api/v1/timelines/home?max_id=110325833875167958&limit=40 HTTP/1.1" 429 None | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment