Пример #1
0
def avxperten(link):
    '''Get name of product from AvXperten-link.'''
    response = requests.get(link)
    html_soup = BeautifulSoup(response.text, 'html.parser')
    name = html_soup.find('div', class_='content-head').text.strip().lower()
    name = change_name(name)
    return name
Пример #2
0
def elgiganten(link):
    '''Get name of product from Elgiganten-link.'''
    response = requests.get(link)
    html_soup = BeautifulSoup(response.text, 'html.parser')
    name = html_soup.find('h1', class_='product-title').text.lower()
    name = change_name(name)
    return name
Пример #3
0
def computersalg(link):
    '''Get name of product from Computersalg-link.'''
    response = requests.get(link)
    html_soup = BeautifulSoup(response.text, 'html.parser')
    name = html_soup.find('h1', itemprop='name').text.lower()
    name = change_name(name)
    return name
Пример #4
0
def proshop(link):
    '''Get name of product from Proshop-link.'''
    response = requests.get(link)
    html_soup = BeautifulSoup(response.text, 'html.parser')
    name = html_soup.find('div', class_='col-xs-12 col-sm-7').h1.text.lower()
    name = change_name(name)
    return name
Пример #5
0
def komplett(link):
    '''Get name of product from Komplett-link.'''
    response = requests.get(link)
    html_soup = BeautifulSoup(response.text, 'html.parser')
    name = html_soup.find('div', class_='product-main-info__info').h1.span.text.lower()
    name = change_name(name)
    return name
Пример #6
0
def get_product_name(link):
    """Get and return name of the product from the link."""
    URL_domain = link.split('/')[2]

    headers = {
        "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36"
    }
    cookies = dict(cookies_are='working')
    response = requests.get(link, headers=headers, cookies=cookies)
    html_soup = BeautifulSoup(response.text, 'html.parser')

    if URL_domain == 'www.komplett.dk':
        return change_name(
            html_soup.find(
                'div', class_='product-main-info__info').h1.span.text.lower())
    elif URL_domain == 'www.proshop.dk':
        return change_name(
            html_soup.find('div', class_='col-xs-12 col-sm-7').h1.text.lower())
    elif URL_domain == 'www.computersalg.dk':
        return change_name(html_soup.find('h1', itemprop='name').text.lower())
    elif URL_domain == 'www.elgiganten.dk':
        return change_name(
            html_soup.find('h1', class_='product-title').text.lower())
    elif URL_domain == 'www.avxperten.dk':
        return change_name(
            html_soup.find('div', class_='content-head').text.strip().lower())
    elif URL_domain == 'www.av-cables.dk':
        return change_name(html_soup.find('h1', class_='title').text.lower())
    elif URL_domain == 'www.amazon.com':
        return change_name(
            html_soup.find('span', id='productTitle').text.strip().lower())
    elif URL_domain == 'www.ebay.com':
        if link.split('/')[3] == 'itm':
            return change_name(link.split('/')[4].replace('-', ' ').lower())
        else:
            return change_name(
                html_soup.find('h1', class_='product-title').text.lower())
    else:
        return None