diff --git a/README.md b/README.md index 366cbcc..10738cf 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,25 @@ -###### Requirements -* [Python](https://www.python.org/downloads/) *(**Note:** This script was developed to be used with the latest version of Python.)* +# pastebin +> python wrapper for the pastebin api -###### API Documentation: -* [Pastebin API](https://pastebin.com/api) +## API Documentation: +* [Pastebin API](https://pastebin.com/doc_api) +* [Pastebin Scraping API](https://pastebin.com/doc_scraping_api) -###### Mirrors -- [acid.vegas](https://acid.vegas/pastebin) *(main)* +## Example: +```python +#!/usr/bin/env python +import pastebin +api_dev_key = 'CHANGEME' +api = pastebin.PasteBin(api_dev_key) +data = open(__file__).read() +result = api.paste(data, guest=True, name='Example Script', format='Python', private='1', expire='10M') +print('PasteBin URL: ' + result) +``` + +**Note**: A posix shell script example can be found [here](https://github.com/acidvegas/random/blob/master/pastebin) + +## Mirrors +- [acid.vegas](https://git.acid.vegas/pastebin) - [SuperNETs](https://git.supernets.org/acidvegas/pastebin) - [GitHub](https://github.com/acidvegas/pastebin) - [GitLab](https://gitlab.com/acidvegas/pastebin) diff --git a/pastebin/pastebin.py b/pastebin.py similarity index 98% rename from pastebin/pastebin.py rename to pastebin.py index cb0575f..7d104bb 100644 --- a/pastebin/pastebin.py +++ b/pastebin.py @@ -1,9 +1,10 @@ #!/usr/bin/env python -# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin) +# PasteBin API Class - Developed by acidvegas in Python (https://git.acid.vegas/pastebin) ''' API Documentation: - https://pastebin.com/api + https://pastebin.com/doc_api + https://pastebin.com/doc_scraping_api ''' import urllib.parse @@ -283,13 +284,13 @@ private_values = { } class PasteBin: - def __init__(self, api_dev_key, api_user_key=None, timeout=10): + def __init__(self, api_dev_key, api_user_key=None): self.api_dev_key = api_dev_key self.api_user_key = api_user_key self.timeout = timeout def api_call(self, method, params): - response = urllib.request.urlopen('https://pastebin.com/api/' + method, urllib.parse.urlencode(params).encode('utf-8'), timeout=self.timeout) + response = urllib.request.urlopen('https://pastebin.com/api/' + method, urllib.parse.urlencode(params).encode('utf-8'), timeout=10) return response.read().decode() def create_user_key(self, username, password): diff --git a/pastebin/example.py b/pastebin/example.py deleted file mode 100644 index 0efa047..0000000 --- a/pastebin/example.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python -# PasteBin API Class - Developed by acidvegas in Python (https://acid.vegas/pastebin) - -import getpass - -import pastebin - -# API Settings -api_dev_key = 'CHANGEME' -api_user_key = None - -# Define API -if api_user_key: - api = pastebin.PasteBin(api_dev_key, api_user_key) -else: - api = pastebin.PasteBin(api_dev_key) - username = input('[?] - Username: ') - password = getpass.getpass('[?] - Password: ') - api_user_key = api.create_user_key(username, password) - if 'Bad API request' not in api_user_key: - print('[+] - You API user key is: ' + api_user_key) - api = pastebin.PasteBin(api_dev_key, api_user_key) - else: - raise SystemExit('[!] - Failed to create API user key! ({0})'.format(api_user_key.split(', ')[1])) - -# Create a Paste -data = open(__file__).read() -result = api.paste(data, guest=True, name='Example Script', format='Python', private='1', expire='10M') -if 'Bad API request' not in result: - print('[+] - PasteBin URL: ' + result) -else: - raise SystemExit('[!] - Failed to create paste! ({0})'.format(api_user_key.split(', ')[1])) \ No newline at end of file