Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Created May 5, 2021 02:00
Show Gist options
  • Save rodrigo-x/68e1a42747289fa73d1aed6358b458fa to your computer and use it in GitHub Desktop.
Save rodrigo-x/68e1a42747289fa73d1aed6358b458fa to your computer and use it in GitHub Desktop.
Pastebin python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import requests
import os
# Sua Key
key = 'L5KcN769zVGXTdmgG5f1gxh3ZpcObgqN'
# Titulo do paste
t_title = 'Novo Paste'
# Arquivo a ser enviado
PATH = os.path.realpath('tkinter_thread.py')
# Faz o read do script
def get_script():
try:
with open(PATH, "r") as file:
contents = file.read()
return contents
except IOError as err:
return err
text = get_script()
login_data = {
'api_dev_key': key,
'api_user_name': 'seu usuario',
'api_user_password': 'sua senha'
}
data = {
'api_option': 'paste',
'api_dev_key': key,
'api_paste_code': text,
'api_paste_name': t_title,
'api_paste_expire_date': '1W',
'api_user_key': None,
'api_paste_format': 'python'
}
def login():
login = requests.post('https://pastebin.com/api/api_login.php', data = login_data)
print('Login status: ', login.status_code if login.status_code != 200 else 'OK/200')
print('User token: ', login.text)
data['api_user_key'] = login.text
login()
def paste():
resposta = requests.post('https://pastebin.com/api/api_post.php', data = data)
print('Enviado: ', resposta.status_code if resposta.status_code != 200 else 'OK/200')
print('URL: ', resposta.text)
paste()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment