Package to read and upload code/text to pastebin.com.
Project description
Pasteconnect package
PasteConnect is a Python library for interacting with Pastebin. It allows you to check account validity, authenticate, create pastes, delete pastes, and retrieve raw paste content.
Installation
Python 3.7 or higher is required.
You can install PasteConnect using pip
:
+$ pip install pasteconnect
Install from source repository
+$ pip install git+https://github.com/heartlog/pasteconnect.git
Getting Started
To get(create) your
username
,password
» login to your pastebin accountafter creating your account, head over to the api documentation and grab your
api_key
under Your Unique Developer API Key
Usage
from pasteconnect import PasteConn
# Sync Client
pastebin = PasteConn(username, password, api_key)
# Account_status(check validity of account)
account_status = pastebin.check_account()
print(account_status)
title = "My Paste Title"
content = "This is the content of my paste."
# Paste text to pastebin
paste_url = pastebin.create_paste(title, content, privacy=1)
print(f"Paste created: {paste_url}")
Initialize client
pastebin = PasteConn(username, password, api_key)
-required for other modules to work
Refer Getting Started
username = "username"
password = "*******"
api_key = "123456abcdefg"
# Define Client
pastebin = PasteConn(username, password, api_key)
Alternatively, you can initialize with predefined environment variables
pastebin = PasteConn() # with pre define env var
Check account existance
pastebin.check_account()
Check validity of pastebin.com account.
result = pastebin.check_account()
print(result) # Response: '[heartlog] is Valid Account. User key : "user_key"'
Authentication
To authenticate and get your user_key
:
pastebin.auth()
Get user_key
using give credentials.
result = pastebin.auth()
print(result) # Response: "user_key"
pastebin.create_paste(title, content, privacy=1)
# 0 : public | 1 : unlisted | 2 : private
privacy = 1 # (default - private)
title = "Title of paste"
content = """
Hello
This is multiline text
"""
pastebin.create_paste(title, content, privacy=1)
pastebin.delete_paste(url)
url = "https://pastebin.com/kZATAWhe"
result = pastebin.delete_paste(url)
print(result) # Response: "Paste Removed"
Get raw content
To retrieve the raw content of a paste using its URL or ID:
pastebin.get_raw_content(url)
from pasteconnect import get_raw
result = get_raw(url)
print(result)
Alternatively, you can use the get_raw
function:
url = "https://pastebin.com/kZATAWhe"
result = pastebin.get_raw_content(url)
print(result) # Response: "Content of paste"
Made with ❤️ by Heartlog
Special Thanks
venaxyt for pastebinapi. Helped a lot in project. 😁
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pasteconnect-0.6.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1970c2405269990b49cb466f06754ffcc80d0b8be605dff3520386caa7524519 |
|
MD5 | d51a4a809b3c2295e1e67574c64186ea |
|
BLAKE2b-256 | 8bb6bca34c73a43b577963cf4e51acfe326947a41c48ddfe218b6df2161a1396 |