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