2017-02-19 13:26:22 +03:00
|
|
|
import requests
|
2017-02-23 14:13:03 +03:00
|
|
|
|
2018-05-22 20:44:18 +03:00
|
|
|
class PrivateBin:
|
2018-05-23 04:14:35 -04:00
|
|
|
def __init__(self, server, proxy=None):
|
2018-05-22 20:44:18 +03:00
|
|
|
self.server = server
|
2017-02-19 13:26:22 +03:00
|
|
|
self.headers = {'X-Requested-With': 'JSONHttpRequest'}
|
2018-05-23 04:14:35 -04:00
|
|
|
if proxy:
|
2018-05-22 20:44:18 +03:00
|
|
|
self.proxy = {proxy.split('://')[0]: proxy}
|
2018-02-12 17:28:18 +03:00
|
|
|
else:
|
2018-05-22 20:44:18 +03:00
|
|
|
self.proxy = {}
|
2017-02-20 15:13:42 +03:00
|
|
|
|
2018-05-22 19:26:49 +03:00
|
|
|
|
2017-02-20 15:13:42 +03:00
|
|
|
def post(self, request):
|
2018-05-22 20:44:18 +03:00
|
|
|
r = requests.post(url = self.server, headers = self.headers, proxies = self.proxy, data = request)
|
2017-03-02 13:09:52 +03:00
|
|
|
return r.text
|
2017-02-20 15:13:42 +03:00
|
|
|
|
|
|
|
|
|
|
|
def get(self, request):
|
|
|
|
url = self.server + "?" + request
|
2018-05-22 20:44:18 +03:00
|
|
|
r = requests.get(url = url, headers = self.headers, proxies = self.proxy)
|
2017-02-20 15:13:42 +03:00
|
|
|
return r.text
|
|
|
|
|
|
|
|
|
2017-02-20 20:56:37 +03:00
|
|
|
def delete(self, pasteid, token):
|
|
|
|
request = {'pasteid':pasteid,'deletetoken':token}
|
2018-05-22 20:44:18 +03:00
|
|
|
r = requests.post(url = self.server, headers = self.headers, proxies = self.proxy, data = request)
|
2017-02-20 15:13:42 +03:00
|
|
|
return r.text
|