<commit_before>#! python2
# [SublimeLinter @python:2]

__author__ = '<NAME>'
__version__ = ''

import logging
import os
import requests
import bs4

log = logging.getLogger(__name__).addHandler(logging.NullHandler())


def get_image_url(webpage):
    """ Function to parse a webpage and get an image's url.

    The function looks for a tag "<div id='comic'>". It then looks if within
    the div tag there is an image tag (<img>).

    If the above is true it returns the image's url. Otherwise it returns none.
    """

    # Getting the webpage
    res = get_resource(webpage)

    # parsing the webpage
    soup = bs4.BeautifulSoup(res.text, "html.parser")
    image_element = soup.select('#comic img')

    if image_element > 0:
        return 'http:{0}'.format(image_element[0].get('src'))
    else:
        log.error('{0}:{1}'.format(webpage, 'image not found'))

        return None


def download_image(url, path):
    """ This function downloads and saves the image specified
    by the given url.

    The image is saved in the specified path.<commit_msg>Changed the internals of get_comic_url function<commit_after>#! python2
# [SublimeLinter @python:2]

__author__ = '<NAME>'
__version__ = ''

import logging
import os
import requests

log = logging.getLogger(__name__).addHandler(logging.NullHandler())


def get_image_url(webpage):
    """ Function to parse a webpage and get an image's url.

    The webpage url should point to it's json format.

    If the above is true it returns the image's url. Otherwise it returns none.
    """

    # Getting the webpage
    res = get_resource(webpage)

    webpage = res.json()

    try:
        return webpage['img']
    except Exception:
        log.error('{0}:{1}'.format(webpage, 'image not found'))

        return None


def download_image(url, path):
    """ This function downloads and saves the image specified
    by the given url.

    The image is saved in the specified path.
{'fraction_non_alphanumeric': 0.1038560411311054, 'fraction_numerical': 0.006683804627249357, 'mean_word_length': 3.34375, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2296494', 'n_tokens_mistral': 607, 'n_tokens_neox': 568, 'n_words': 209}