# Path: app/aml_utils.py
# def getpage(url):
#     """
#     Downloads the html page
# 
#     :rtype: tuple
#     :param url: the page address
#     :return: the header response and contents (bytes) of the page
#     """
#     http = httplib2.Http('.cache', disable_ssl_certificate_validation=True)
#     headers = {
#         'User-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'}
# 
#     response, content = http.request(url, headers=headers)
#     return response, content
# 
# def parsepage(content):
#     """
#     Parses a single page and its contents into a BeautifulSoup object
# 
#     :param content: bytearray
#     :return soup: object
#     """
#     soup = BeautifulSoup(content, 'lxml')
#     return soup
# 
# def get_ns(key):
#     """
#     Gets a news_source filtered by key
#     :param key: the key of the news source (e.g: g1, uol, etc.)
#     :return: the news source object
#     """
#     ns = NewsSource.query.filter_by(
#         key=key).first()  # Fetch news source by key
#     return ns


from app.aml_utils import getpage, parsepage, get_ns
"""
news_source_sports.py: Scraping functions for the most read  News Sources of the Sports Category

__author__ = "Fernando P. Lopes"
__email__ = "fpedrosa@gmail.com"

"""


def __e_fox_br(soup):
    """
    Gets the most read news from the Fox Sports page
    :param soup: the BeautifulSoup object
    :return: a list with the most read news from the Fox Sports page
    """
    news = []

# Path: app/aml_utils.py
# def getpage(url):
#     """
#     Downloads the html page
# 
#     :rtype: tuple
#     :param url: the page address
#     :return: the header response and contents (bytes) of the page
#     """
#     http = httplib2.Http('.cache', disable_ssl_certificate_validation=True)
#     headers = {
#         'User-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'}
# 
#     response, content = http.request(url, headers=headers)
#     return response, content
# 
# def parsepage(content):
#     """
#     Parses a single page and its contents into a BeautifulSoup object
# 
#     :param content: bytearray
#     :return soup: object
#     """
#     soup = BeautifulSoup(content, 'lxml')
#     return soup
# 
# def get_ns(key):
#     """
#     Gets a news_source filtered by key
#     :param key: the key of the news source (e.g: g1, uol, etc.)
#     :return: the news source object
#     """
#     ns = NewsSource.query.filter_by(
#         key=key).first()  # Fetch news source by key
#     return ns


# Path: app/news_source_sports.py
from app.aml_utils import getpage, parsepage, get_ns

"""
news_source_sports.py: Scraping functions for the most read  News Sources of the Sports Category

__author__ = "Fernando P. Lopes"
__email__ = "fpedrosa@gmail.com"

"""


def __e_fox_br(soup):
    """
    Gets the most read news from the Fox Sports page
    :param soup: the BeautifulSoup object
    :return: a list with the most read news from the Fox Sports page
    """
    news = []

    ns = get_ns('e_fox_br')