Ejemplo n.º 1
0
def get_thumbnails():
    """Get images  in JSON format."""
    return jsonify({
        'error': None,
        'message': "Success",
        'thumbnails': get_images()
    })
Ejemplo n.º 2
0
def thumbnail():
    url = "https://www.walmart.com/ip/54649026"
    imagelist = get_images(url)
    for each in imagelist:
        if not each.lower().endswith(('.png', '.jpg', '.jpeg')):
            imagelist.remove(each)
    imagelist = list(set(imagelist))
    output = jsonify(error="null", message="Success", thumbnails=imagelist)
    return output
Ejemplo n.º 3
0
def scrapeImages():
    """Accepts a url and returns JSON containing a list of thumbnails."""
    if request.is_json:
        Webpage = request.get_json(force=True)
        print Webpage["url"]
        images = {
            "error": "null",
            "message": "Success",
            "thumbnails": get_images(Webpage["url"])
        }
        print "success"
    else:
        images = {
            "error": "true",
            "data": {},
            "message": "Unable to extract thumbnails"
        }
        print "failed"
    print "returning"
    return jsonify(images)
Ejemplo n.º 4
0
def api_thumbnails():

    user = auth_user(request.authorization)

    if user is None:
        output = {
            "error": True,
            "data": {},
            "message": "Authorization failure"
        }
    else:
        if 'url' not in request.args:
            output = {
                "error": True,
                "data": {},
                "message": "Invalid request format"
            }
        else:

            data = {"thumbnails": get_images(request.args.get('url'))}

            output = {"error": None, "data": data, "message": "Success"}
    return json.dumps(output, indent=4, sort_keys=True)
Ejemplo n.º 5
0
def api_thumbnails():
    output = {"error": None, "message": "Success", "thumbnails": get_images()}
    return json.dumps(output, indent=4, sort_keys=True)
Ejemplo n.º 6
0
def images():
    """Returns JSON of links to all images on a website's page."""
    images = {"error": "null", "message":"Success","thumbnails": get_images()}
    return jsonify(images)
Ejemplo n.º 7
0
def thumbnails(url):
    return jsonify(error=None,
                   message="Success",
                   thumbnails=image_getter.get_images(url))