Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #post to pastebin automation
- #the program will launch and will ask the user to enter the file path and enter paste name
- #the program will post the source code of the file in pastebin
- #you will need an api_dev_key and api_user_key to perform this automation
- #get the api_dev_key from https://pastebin.com/doc_api
- #create a creds.py file and store your keys as api_dev_key and api_user_key
- #import creds in the main file
- #run the program from terminal
- #script writtern by Ayan Upadhaya, contact: ayanU881@gmail.com
- import requests
- from creds import*
- class Pastebin:
- def __init__(self):
- self.API_ENDPOINT="https://pastebin.com/api/api_post.php"
- self.api_dev_key = api_dev_key
- self.api_user_key = api_user_key
- def post_pastebin(self,file_path,paste_name):
- with open(file_path,'r') as f:
- source_data=f.read()
- data={
- 'api_dev_key':self.api_dev_key,
- 'api_user_key':self.api_user_key,
- 'api_option':'paste',
- 'api_paste_code':source_data,
- 'api_paste_name':paste_name,}
- r=requests.post(url=self.API_ENDPOINT,data=data)
- print(r)
- print(r.text)
- """
- generate user key for posting as pastebin member
- ================================================
- from https://pastebin.com/doc_api get the api_dev_key
- to generate the user key create a separate py file, copy the below codes.
- Then pass your api_dev_key, your username and password of pastebin as arguments(line: 57) in generate_user_key funtion()
- This will return an user key. copy that and save it in your creds.py file as api_user_key variable
- """
- """
- def generate_user_key(api_dev_key,api_user_name,api_user_password):
- API_ENDPOINT="https://pastebin.com/api/api_login.php"
- data={
- 'api_dev_key':api_dev_key,
- 'api_user_name':api_user_name,
- 'api_user_password':api_user_password
- }
- r=requests.post(url=API_ENDPOINT,data=data)
- return r.text
- print(generate_user_key(api_dev_key,api_user_name,api_user_password))
- """
- def main():
- file_path=input("Enter the file path:")
- paste_name=input("Enter paste name:")
- try:
- paste=Pastebin()
- paste.post_pastebin(file_path,paste_name)
- except Exception as e:
- print(e)
- if __name__=="__main__":
- main()
Add Comment
Please, Sign In to add comment