21 lines
537 B
Python
21 lines
537 B
Python
import requests
|
|
|
|
def upload(data):
|
|
url = 'https://paste2.org/'
|
|
|
|
response = requests.post(url, data={'data': data})
|
|
response.raise_for_status()
|
|
|
|
# Extract the URL of the uploaded paste from the response
|
|
paste_url = None
|
|
for line in response.text.splitlines():
|
|
if line.startswith('<input type="text" id="paste-url" value="'):
|
|
paste_url = line.split('"')[3]
|
|
break
|
|
|
|
if paste_url is None:
|
|
raise ValueError('Could not extract paste URL from response')
|
|
|
|
return paste_url
|
|
|