· 5 years ago · Sep 13, 2020, 01:56 AM
1
2# Post limit, maximum pastes per 24h = 10 POST req
3
4
5from urllib.request import urlopen
6import urllib.parse
7
8# To know your API key, sign in to your paste bin account
9# and go to https://pastebin.com/doc_api#1
10PASTEBIN_KEY = 'Your Unique Developer API Key'
11
12
13# If you don't want to paste from your paste bin account
14# then comment out the code from line no. 16 - 25
15
16# code to get a api_user_key
17PASTEBIN_URL = 'https://pastebin.com/api/api_login.php'
18pastebin_vars = dict(
19 api_user_name='Your USER_NAME',
20 api_dev_key=PASTEBIN_KEY,
21 api_user_password='Your PASSWORD',
22)
23
24USER_KEY = urlopen(urllib.request.Request(PASTEBIN_URL, urllib.parse.urlencode(pastebin_vars).encode('utf8'))).read().decode("utf-8")
25
26
27
28# your code goes between (there must be three single qoutes, not two)
29source_code = ''
30
31''
32
33# post request to paste
34PASTEBIN_URL = 'https://pastebin.com/api/api_post.php'
35pastebin_vars = dict(
36 api_user_key=USER_KEY,
37 api_option='paste',
38 api_dev_key=PASTEBIN_KEY,
39 api_paste_name='pastebin_API_python',
40 api_paste_code=source_code,
41 api_paste_format='python',
42)
43
44print(urlopen(urllib.request.Request(PASTEBIN_URL, urllib.parse.urlencode(pastebin_vars).encode('utf8'))).read().decode("utf-8"))
45
46