PBinCLI/pbincli/transports.py

29 lines
961 B
Python
Raw Normal View History

2017-02-19 13:26:22 +03:00
import requests
2017-03-02 13:09:52 +03:00
import pbincli.settings
2018-05-22 20:44:18 +03:00
class PrivateBin:
def __init__(self, server = pbincli.settings.server, proxy = pbincli.settings.proxy, useproxy = pbincli.settings.useproxy):
self.server = server
2017-02-19 13:26:22 +03:00
self.headers = {'X-Requested-With': 'JSONHttpRequest'}
2018-05-22 20:44:18 +03:00
if useproxy:
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
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