import requests
import random


def image_fetch(url, file_path):
    """
    Fetch image from the internet.

    Parameters:
    url (string): A image url

    file_path (string): Directory name where the image will be saved.

    Output:
    url's image will be saved in the file_path directory

    """
    response = requests.get(url)
    image_name = random.randint(1,10000)  ## A random name assign to each image fetched.
    fetched_image_name = file_path + str(image_name) + '.jpg' ## saving the image as jpg

    if response.status_code == 200:
        with open(fetched_image_name, 'wb') as f:
            f.write(response.content)

    return response.status_code