#!/usr/bin/env python
# -*- coding: utf-8 -*-

import json

from pprint import pprint
import requests


def parse_html(html):
    return html.splitlines()


def upload(f):
    url = 'http://www.bild.me/index.php'
    data = {
        't': 1,
        'C1': 'ON',
        'upload': 1,
    }
    files = {
        'F1': f
    }
    try:
        html = requests.post(url, data=data, files=files).text
        return {'status': 0, 'result': parse_html(html)}
    except requests.exceptions:
        return {'status': 1, 'message': 'Upload failed!'}


def main():
    f = open('test.jpg', 'rb')
    pprint(upload(f))

if __name__ == '__main__':
    main()

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from argparse import ArgumentParser
import json

import requests

__version__ = '0.1.0'


def parse_html(html):
    return html.splitlines()


def upload(f):
    url = 'http://www.bild.me/index.php'
    data = {
        't': 1,
        'C1': 'ON',
        'upload': 1,
    }
    files = {
        'F1': f
    }
    try:
        html = requests.post(url, data=data, files=files).text
        return {'status': 0, 'result': parse_html(html)}
    except requests.exceptions:
        return {'status': 1, 'message': 'Upload failed!'}


def main():
    parser = ArgumentParser(description='CIL tool for bild.me.')
    parser.add_argument('-V', '--version', action='version',
                        version=__version__)
    parser.add_argument('-l', '--list', action='store_true',
                        help='list all result')
    parser.add_argument('file', help='picture file')
    args = parser.parse_args()

    f = open(args.file, 'rb')
    result = upload(f)

    if result['status'] == 1:
        return result['message']

    if args.list:
        return '\n\n'.join(result['result'])
    else:
        return result['result'][5]

if __name__ == '__main__':
    print(main())

add command-line arguments