# Path: botty_mcbotface/utils/tools.py
# def get_html(url):
#     """
#     Return a BeautifulSoup
#     :param url: URL to get HTML from
#     :return: HTML of requested URL.
#     """
#     res = requests.get(url)
#     s = soup(res.text)
# 
#     return s


from botty_mcbotface.utils.tools import get_html
from six.moves.urllib.parse import unquote
from slackbot.bot import listen_to, re
import urllib.parse
    """

    search_url = google_base_url + urllib.parse.quote_plus(search)
    results = get_html(search_url).select('div.g h3.r a')

    # Indicators for google search links
    g_link_test = re.compile(r'/search\?q=')

    try:
        # Skip the first link if it's a google search link (images, news etc)
        first_result = next(l for l in results if not re.search(g_link_test, str(l)))

        # Remove google link tracking metadata from URL
        link = re.sub(r'^/url\?q=', '', first_result['href']).split('&sa=', 1)[0]

        return message.send(unquote(link))

    except StopIteration:
        return message.send('No Google results for that search... sorry :/')


@listen_to('^\.y (.*)', re.IGNORECASE)
def youtube(message, search):
    """
    Performs a youtube search and returns 1st result
    :param message: Slackbot message object
    :param search: User search string
    :return: Message to slack channel
    """
    search_url = youtube_base_url + search

# Path: botty_mcbotface/utils/tools.py
# def get_html(url):
#     """
#     Return a BeautifulSoup
#     :param url: URL to get HTML from
#     :return: HTML of requested URL.
#     """
#     res = requests.get(url)
#     s = soup(res.text)
# 
#     return s


# Path: botty_mcbotface/plugins/searches.py
from botty_mcbotface.utils.tools import get_html
from six.moves.urllib.parse import unquote
from slackbot.bot import listen_to, re
import urllib.parse

    """

    search_url = google_base_url + urllib.parse.quote_plus(search)
    results = get_html(search_url).select('div.g h3.r a')

    # Indicators for google search links
    g_link_test = re.compile(r'/search\?q=')

    try:
        # Skip the first link if it's a google search link (images, news etc)
        first_result = next(l for l in results if not re.search(g_link_test, str(l)))

        # Remove google link tracking metadata from URL
        link = re.sub(r'^/url\?q=', '', first_result['href']).split('&sa=', 1)[0]

        return message.send(unquote(link))

    except StopIteration:
        return message.send('No Google results for that search... sorry :/')


@listen_to('^\.y (.*)', re.IGNORECASE)
def youtube(message, search):
    """
    Performs a youtube search and returns 1st result
    :param message: Slackbot message object
    :param search: User search string
    :return: Message to slack channel
    """
    search_url = youtube_base_url + search

    results = get_html(search_url).select('a.yt-uix-sessionlink')