from bs4 import BeautifulSoup
import requests
import re

# strips everything from the 'style'-tag in which the URL is hidden:
# style="background-image:url(https://66.media.tumblr.com/5e951bc325a1b9d53539b241cb542a43/tumblr_pqydiv0VX31rfcxgro1_500.png)"
regex = re.compile('.*?\\((.*?)\\)')


def get_stage_images_from_URL(URL):
    """Gets a list of image URL's from given Tumblr-URL

    Parameters:
    URL (string): URL of meme-tagged page

    Returns:
    Array of URL's
   """
    results = []

    page = requests.get(URL)
    imageList = BeautifulSoup(page.content, 'html.parser')

    for link in imageList.findAll('div', {'class': 'photo_stage_img'}):
        imageURL = re.findall(regex, link['style'])
        results.append(imageURL[0])

    return results


def get_hashtags_from_URL(URL):
    """Returns a list of hashtags from a given Tumblr-URL

    Parameters:
    URL (string): URL of meme-tagged page

    Returns:
    List of hashtags
   """
    results = []

    page = requests.get(URL)
    imageList = BeautifulSoup(page.content, 'html.parser')

    for link in imageList.findAll('a', {'class': 'post_tag'}):
        hashtag = link.text
        results.append(hashtag)

    return results

from bs4 import BeautifulSoup
import requests
import re

# strips everything from the 'style'-tag in which the URL is hidden:
# style="background-image:url(https://66.media.tumblr.com/5e951bc325a1b9d53539b241cb542a43/tumblr_pqydiv0VX31rfcxgro1_500.png)"
regex = re.compile('.*?\\((.*?)\\)')


def get_stage_images_from_URL(URL):
    """Gets a list of image URL's from given Tumblr-URL

    Parameters:
    URL (string): URL of meme-tagged page

    Returns:
    Array of URL's
   """
    results = []

    page = requests.get(URL)
    imageList = BeautifulSoup(page.content, 'html.parser')

    for link in imageList.findAll('div', {'class': 'photo_stage_img'}):
        imageURL = re.findall(regex, link['style'])
        results.append(imageURL[0])

    return results


def get_hashtags_from_URL(URL):
    """Returns a list of hashtags from a given Tumblr-URL

    Parameters:
    URL (string): URL of meme-tagged page

    Returns:
    List of hashtags
   """
    results = []

    page = requests.get(URL)
    imageList = BeautifulSoup(page.content, 'html.parser')

    for link in imageList.findAll('a', {'class': 'post_tag'}):
        hashtag = link.text
        results.append(hashtag)

    return results

# strips everything from the 'style'-tag in which the URL is hidden: # style="background-image:url(https://66.media.tumblr.com/5e951bc325a1b9d53539b241cb542a43/tumblr_pqydiv0VX31rfcxgro1_500.png)" Gets a list of image URL's from given Tumblr-URL      Parameters:     URL (string): URL of meme-tagged page      Returns:     Array of URL's Returns a list of hashtags from a given Tumblr-URL      Parameters:     URL (string): URL of meme-tagged page      Returns:     List of hashtags