pasteconnect
0.6.2
CasteConnect是用於與Pastebin互動的Python庫。它允許您檢查帳戶有效性,身份驗證,創建糊狀,刪除糊狀並檢索RAW PADTE含量。
需要Python 3.7或更高。
您可以使用pip安裝過去的連接:
+ $ pip install pasteconnect從源存儲庫安裝
+ $ pip install git+https://github.com/heartlog/pasteconnect.git要使用casteconnect,您需要粘貼憑證,其中包括您的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 } " )要與casteconnect互動,您需要用憑據初始化客戶端:
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帳戶的有效性:
pastebin.check_account() result = pastebin . check_account ()
print ( result ) # Response: '[heartlog] is Valid Account. User key : "user_key"' 要身份驗證並獲取您的user_key ,請使用auth()方法:
pastebin.auth()使用憑據獲取user_key 。
result = pastebin . auth ()
print ( result ) # Response: "user_key" 您可以在Pastebin上創建具有標題,內容和隱私級別的糊狀物。隱私級別可以是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 for Pastebinapi。在項目中有很大幫助。 ?