You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
832 B
Python
20 lines
832 B
Python
from mastodon import Mastodon
|
|
|
|
with open('token.txt','r') as token: # getting token from toke.txt file
|
|
mastodon = Mastodon(access_token=token.read(),api_base_url="https://post.lurk.org/")
|
|
|
|
# search(q, resolve=False) method of mastodon.Mastodon.Mastodon instance
|
|
# Fetch matching hashtags, accounts and statuses. Will search federated
|
|
# instances if resolve is True. Full-text search is only enabled if
|
|
# the instance supports it, and is restricted to statuses the logged-in
|
|
# user wrote or was mentioned in.
|
|
|
|
# search
|
|
searchresult = mastodon.search("cat")
|
|
|
|
print(searchresult.keys()) #.search returns a dictionary w/ they keys ['accounts', 'hashtags', 'statuses']
|
|
|
|
for cat_account in searchresult['accounts']: # loop through all accounts
|
|
print(cat_account)
|
|
print(cat_account['username'], cat_account['url'])
|