Skip to content

Instantly share code, notes, and snippets.

@monsieurh
Created July 22, 2016 10:44
Show Gist options
  • Save monsieurh/2c33bcc2258bb29a8fde177103780ecc to your computer and use it in GitHub Desktop.
Save monsieurh/2c33bcc2258bb29a8fde177103780ecc to your computer and use it in GitHub Desktop.
Uploads an image to LUTIM (http://lut.im/)
#!/usr/bin/env python3
import argparse
import os
import sys
import requests
from bs4 import BeautifulSoup
def main():
parser = argparse.ArgumentParser("LUTIM")
parser.add_argument("image_path", nargs=1)
config = parser.parse_args()
if not os.path.isfile(config.image_path[0]):
print("Could not find file '%s'" % config.image_path[0], file=sys.stderr)
exit(-1)
files_dict = {'file': open(config.image_path[0], 'rb')}
response = requests.post("https://lut.im/", files=files_dict)
print(response.url, response.status_code)
soup = BeautifulSoup(response.text, 'html.parser')
view_url = soup.find(id="view")["value"]
del_url = soup.find("a", title="Deletion link")["href"]
print("View :\t%s" % view_url)
print("Del :\t%s" % del_url)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment