pasteconnect
0.6.2
PasteConnectは、パスペビンと対話するためのPythonライブラリです。アカウントの妥当性を確認し、認証し、ペーストを作成し、ペーストを削除し、生のペーストコンテンツを取得できます。
Python 3.7以上が必要です。
pipを使用してPasteConnectをインストールできます。
+ $ pip install pasteconnectソースリポジトリからインストールします
+ $ pip install git+https://github.com/heartlog/pasteconnect.git PasteConnectを使用するには、 username 、 password 、 api_keyを含むパスペビン資格情報が必要です。これらを持っていない場合は、PastebinアカウントにサインアップしてPastebin APIドキュメントからapi_keyを生成することでそれらを取得できます。
from pasteconnect import PasteConn
# Initialize a PasteConnect client
pastebin = PasteConn ( username , password , api_key )
# Check account validity
account_status = pastebin . check_account ()
print ( account_status )
title = "My Paste Title"
content = "This is the content of my paste."
# Create a paste on Pastebin
paste_url = pastebin . create_paste ( title , content , privacy = 1 )
print ( f"Paste created: { paste_url } " )PasteConnectと対話するには、クライアントを資格情報で初期化する必要があります。
pastebin = PasteConn(username, password, api_key) - required for other methods to work開始を参照してください
username = "your_username"
password = "your_password"
api_key = "your_api_key"
# Initialize the client
pastebin = PasteConn ( username , password , api_key )または、事前定義された環境変数で初期化することもできます
pastebin = PasteConn () # with pre define env var 次の方法を使用して、パステビンアカウントの妥当性を確認できます。
pastebin.check_account() result = pastebin . check_account ()
print ( result ) # Response: '[heartlog] is Valid Account. User key : "user_key"' user_key認証して取得するには、 auth()メソッドを使用します。
pastebin.auth() give credentialsを使用してuser_keyを取得します。
result = pastebin . auth ()
print ( result ) # Response: "user_key" タイトル、コンテンツ、プライバシーレベルを備えたパステビンにペーストを作成できます。プライバシーレベルは、0(パブリック)、1(非公開)、または2(プライベート)になります。
pastebin.create_paste(title, content, privacy=1) privacy = 1 # (default - private)
title = "Title of paste"
content = """
Hello
This is multiline text
"""
pastebin . create_paste ( title , content , privacy = 1 )ペーストを削除するには、 delete_paste(url)メソッドを使用してURLまたはIDを提供します。
pastebin.delete_paste(url) url = "https://pastebin.com/kZATAWhe"
result = pastebin . delete_paste ( url )
print ( result ) # Response: "Paste Removed" URLまたはIDを使用して、ペーストの生のコンテンツを取得できます。
pastebin.get_raw_content(url) from pasteconnect import get_raw
result = get_raw ( url )
print ( result )または、 get_raw関数を使用できます。
url = "https://pastebin.com/your_paste_id"
result = pastebin . get_raw_content ( url )
print ( result ) # Response: "Content of paste"パステビナピ用のvenaxyt。プロジェクトで大いに役立ちました。 ?