コード例 #1
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        car_model_name = car_model_tag['name']
        car_model_id = car_model_tag['value']
        print(car_model_name)
        model, created = Model.objects.get_or_create(name=car_model_name,
                                                     brand=brand)
        site_model = SiteModel()
        site_model.site = site
        site_model.model = model
        site_model.identifier = car_model_id
        site_model.save()
        results.append(site_model)
    return results
コード例 #2
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        car_model_name = ' '.join(car_model_tag.string.split())
        print(car_model_name)
        car_model_id = car_model_tag['data-val']
        model, created = Model.objects.get_or_create(name=car_model_name,
                                                     brand=brand)
        site_model = SiteModel()
        site_model.site = site
        site_model.model = model
        site_model.identifier = car_model_id
        site_model.save()
        results.append(site_model)
    return results
コード例 #3
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        car_model_name = ' '.join(car_model_tag.string.split())
	print(car_model_name)
        car_model_id = car_model_tag['data-val']
	model, created = Model.objects.get_or_create(name=car_model_name, brand=brand)
        site_model = SiteModel()
	site_model.site = site
	site_model.model = model
	site_model.identifier = car_model_id
	site_model.save()
        results.append(site_model)
    return results
コード例 #4
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        car_model_name = car_model_tag['name']
        car_model_id = car_model_tag['value']
	print(car_model_name)
	model, created = Model.objects.get_or_create(name=car_model_name, brand=brand)
        site_model = SiteModel()
	site_model.site = site
	site_model.model = model
	site_model.identifier = car_model_id
	site_model.save()
        results.append(site_model)
    return results
コード例 #5
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        search = re.search('^(.+) \(\d*\)', car_model_tag.text.encode('utf-8'))
        if search is None:
            continue
        car_model_string = search.group(1)
        car_model_name = ' '.join(car_model_string.split())
        car_model_id = car_model_tag['value']
        model, created = Model.objects.get_or_create(name=car_model_name,
                                                     brand=brand)
        site_model = SiteModel()
        site_model.site = site
        site_model.model = model
        site_model.identifier = car_model_id
        site_model.save()
        results.append(site_model)
    return results
コード例 #6
0
def get_car_models_and_ids(car_model_tags, site, brand):
    results = []
    for car_model_tag in car_model_tags:
        search = re.search('^(.+) \(\d*\)', car_model_tag.text.encode('utf-8'))
        if search is None:
            continue
        car_model_string = search.group(1)
        car_model_name = ' '.join(car_model_string.split())
        car_model_id = car_model_tag['value']
	model, created = Model.objects.get_or_create(name=car_model_name, brand=brand)
        site_model = SiteModel()
	site_model.site = site
	site_model.model = model
	site_model.identifier = car_model_id
	site_model.save()
        results.append(site_model)
    return results