Mastodon
Mastodon 是一個聯合的社群媒體和社交網路服務。
這個載入器使用 Mastodon.py
Python 套件,從一組 Mastodon
帳號的「嘟文」(toots) 中提取文字。
預設情況下,無需任何身份驗證即可查詢公開帳號。 如果查詢非公開帳號或實例,則必須為您的帳號註冊一個應用程式,該應用程式會為您提供一個存取權杖,並設定該權杖和您帳號的 API 基本 URL。
然後,您需要以 @帳號@實例
格式傳入您想要提取的 Mastodon 帳號名稱。
from langchain_community.document_loaders import MastodonTootsLoader
API 參考:MastodonTootsLoader
%pip install --upgrade --quiet Mastodon.py
loader = MastodonTootsLoader(
mastodon_accounts=["@Gargron@mastodon.social"],
number_toots=50, # Default value is 100
)
# Or set up access information to use a Mastodon app.
# Note that the access token can either be passed into
# constructor or you can set the environment "MASTODON_ACCESS_TOKEN".
# loader = MastodonTootsLoader(
# access_token="<ACCESS TOKEN OF MASTODON APP>",
# api_base_url="<API BASE URL OF MASTODON APP INSTANCE>",
# mastodon_accounts=["@Gargron@mastodon.social"],
# number_toots=50, # Default value is 100
# )
documents = loader.load()
for doc in documents[:3]:
print(doc.page_content)
print("=" * 80)
<p>It is tough to leave this behind and go back to reality. And some people live here! I’m sure there are downsides but it sounds pretty good to me right now.</p>
================================================================================
<p>I wish we could stay here a little longer, but it is time to go home 🥲</p>
================================================================================
<p>Last day of the honeymoon. And it’s <a href="https://mastodon.social/tags/caturday" class="mention hashtag" rel="tag">#<span>caturday</span></a>! This cute tabby came to the restaurant to beg for food and got some chicken.</p>
================================================================================
嘟文文字(文件的 page_content
)預設為 Mastodon API 傳回的 HTML。