Ejemplo n.º 1
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    car.title = listing_tag.find('span', class_='mp-listing-title').text
    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = listing_tag.find('div', class_='price').text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+)', price_string).group(1)
    except AttributeError:
        price_extracted = ''
    try:
        price_converted = price_extracted.replace('.', '').replace(',', '.')
        price = Decimal(price_converted)
    except:
        price = 0
    car.price = price
    description = listing_tag.find('span', class_='mp-listing-description')
    extended_description = listing_tag.find('span', class_='mp-listing-description-extended')
    car.description = description.text.encode('utf-8')
    if extended_description:
        car.description += extended_description.text.encode('utf-8')
    car.url = listing_tag.find('h2', class_='heading').find('a')['href']
    car.image_url = listing_tag.find('div', class_='listing-image').find('img')['src']
    return car
Ejemplo n.º 2
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    car.title = listing_tag.find('span', class_='mp-listing-title').text
    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = listing_tag.find('div', class_='price').text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+)', price_string).group(1)
    except AttributeError:
        price_extracted = ''
    try:
        price_converted = price_extracted.replace('.', '').replace(',', '.')
        price = Decimal(price_converted)
    except:
        price = 0
    car.price = price
    description = listing_tag.find('span', class_='mp-listing-description')
    extended_description = listing_tag.find(
        'span', class_='mp-listing-description-extended')
    car.description = description.text.encode('utf-8')
    if extended_description:
        car.description += extended_description.text.encode('utf-8')
    car.url = listing_tag.find('h2', class_='heading').find('a')['href']
    car.image_url = listing_tag.find('div',
                                     class_='listing-image').find('img')['src']
    return car
Ejemplo n.º 3
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    header_and_description_div = listing_tag.find(
        'div', class_='position-header-and-description')

    if header_and_description_div is not None:
        title_header = header_and_description_div.find('h2')
        description_paragraph = header_and_description_div.find('p')
        if title_header is not None:
            car.title = title_header.text
        if description_paragraph is not None:
            car.description = description_paragraph.text.encode('utf-8')

    car.brand = brand
    price_string = ''
    price_div = listing_tag.find('div', class_='block half-top-padding')

    if price_div is not None:
        price_string = price_div.find('h2').text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+),-', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price
    model = Model()
    model.name = model_name
    car.model = model
    url_div = listing_tag.find('div', class_='position-list-item-description')

    if url_div is not None:
        car.url = 'http://www.speurders.nl' + url_div.find('a')['href']

    image_div = listing_tag.find('div', class_='list-item-img')
    if image_div is not None:
        style_text = image_div['style']

        if style_text is not None:
            car.image_url = 'http://' + re.search(
                "background-image: url\('//(.+)'\);", style_text).group(1)

    return car
Ejemplo n.º 4
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    header_and_description_div = listing_tag.find('div', class_='position-header-and-description')

    if header_and_description_div is not None:
        title_header = header_and_description_div.find('h2')
        description_paragraph = header_and_description_div.find('p')
        if title_header is not None:
            car.title = title_header.text
        if description_paragraph is not None:
            car.description = description_paragraph.text.encode('utf-8')

    car.brand = brand
    price_string = ''
    price_div = listing_tag.find('div', class_='block half-top-padding')

    if price_div is not None:
        price_string = price_div.find('h2').text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+),-', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price
    model = Model()
    model.name = model_name
    car.model = model
    url_div = listing_tag.find('div', class_='position-list-item-description')

    if url_div is not None:
        car.url = 'http://www.speurders.nl' + url_div.find('a')['href']

    image_div = listing_tag.find('div', class_='list-item-img')
    if image_div is not None:
        style_text = image_div['style']

        if style_text is not None:
            car.image_url = 'http://' + re.search("background-image: url\('//(.+)'\);", style_text).group(1)

    return car
Ejemplo n.º 5
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    link = listing_tag.find('h3').find('a')
    if link is not None:
        car.title = link.text

    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = ''
    price_tag = listing_tag.find('td', class_='prijs').find('strong')

    if price_tag is not None:
        price_string = price_tag.text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+)', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price

    description = listing_tag.find('td', class_='omschrijving').find(
        'span', class_='kenmerken')
    car.description = description.text.encode('utf-8')

    if link is not None:
        car.url = 'http://www.autowereld.nl' + link['href']

    image_tag = listing_tag.find('td', class_='foto').find('img')
    if image_tag is not None:
        car.image_url = 'http://www.autowereld.nl' + image_tag['src']

    return car
Ejemplo n.º 6
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    link = listing_tag.find('h3').find('a')
    if link is not None:
        car.title = link.text

    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = ''
    price_tag = listing_tag.find('td', class_='prijs').find('strong')

    if price_tag is not None:
        price_string = price_tag.text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+)', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price

    description = listing_tag.find('td', class_='omschrijving').find('span', class_='kenmerken')
    car.description = description.text.encode('utf-8')

    if link is not None:
        car.url = 'http://www.autowereld.nl' + link['href']

    image_tag = listing_tag.find('td', class_='foto').find('img')
    if image_tag is not None:
        car.image_url = 'http://www.autowereld.nl' + image_tag['src']

    return car
Ejemplo n.º 7
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    link = listing_tag.find('h2').find('a')
    if link is not None:
        car.title = link['title']

    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = ''
    price_div = listing_tag.find('div', class_='result-price-label')

    if price_div is not None:
        price_string = price_div.text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+),-', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price

    if link is not None:
        car.url = 'http://www.autotrader.nl' + link['href']

    image_tag = listing_tag.find('img', class_='img-rounded')
    if image_tag is not None:
        car.image_url = image_tag['data-src']

    return car
Ejemplo n.º 8
0
def parse_car_listing(listing_tag, brand, model_name):
    car = Car()
    link = listing_tag.find('h2').find('a')
    if link is not None:
        car.title = link['title']

    car.brand = brand
    model = Model()
    model.name = model_name
    car.model = model
    price_string = ''
    price_div = listing_tag.find('div', class_='result-price-label')

    if price_div is not None:
        price_string = price_div.text.encode('utf-8')
    try:
        price_extracted = re.search('€ (.+),-', price_string).group(1)
    except AttributeError:
        price_extracted = ''

    try:
        price_converted = price_extracted.replace('.', '')
        price = Decimal(price_converted)
    except:
        price = 0

    car.price = price

    if link is not None:
        car.url = 'http://www.autotrader.nl' + link['href']

    image_tag = listing_tag.find('img', class_='img-rounded')
    if image_tag is not None:
        car.image_url = image_tag['data-src']

    return car