Created
July 22, 2016 10:44
-
-
Save monsieurh/2c33bcc2258bb29a8fde177103780ecc to your computer and use it in GitHub Desktop.
Uploads an image to LUTIM (http://lut.im/)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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