import bs4
from requests import get
from requests.exceptions import RequestException
from contextlib import closing
from bs4 import BeautifulSoup
import re

def simple_get(url):
    """
    Attempts to get the content at `url` by making an HTTP GET request.
    If the content-type of response is some kind of HTML/XML, return the
    text content, otherwise return None.
    """
    try:
        with closing(get(url, stream=True)) as resp:
            if is_good_response(resp):
                return resp.content
            else:
                return None

    except RequestException as e:
        log_error('Error during requests to {0} : {1}'.format(url, str(e)))
        return None


def is_good_response(resp):
    """
    Returns True if the response seems to be HTML, False otherwise.
    """
    content_type = resp.headers['Content-Type'].lower()
    return (resp.status_code == 200
            and content_type is not None
            and content_type.find('html') > -1)


def log_error(e):
    """
    It is always a good idea to log errors.
    This function just prints them, but you can
    make it do anything.
    """
    print(e)

def Scrapper(option):
    if option == 1:
        MyList = []
        raw_html = simple_get('https://www.marathonbet.ru/su/betting/Football/Internationals/UEFA+Euro/2020/Qualification/Play-Off+Round/1st+Round')
        html = BeautifulSoup(raw_html, 'html.parser')
        z = html.findAll('a', attrs={'class', 'member-link'}, href=True)
        for a in z:
            buff = str(a).replace('<a class="member-link" href="', '').replace('">', '').replace('<span data-member-link="true', '').replace('</span>', '').replace('</a>', '').replace('', '').replace('/su/betting/Football', '')

            MyList.append(buff.split("\n",2)[0])
    return MyList


Scrapper(1)







