Ejemplo n.º 1
0
def telekom_mobil_cartele(scraper_url: str):
    response_body = get_json(scraper_url)
    products_html = response_body['productsHtml']
    soup = bs4.BeautifulSoup(products_html, 'html5lib')

    feature_kw = OrderedDict([
        ('mobil_min_internat', 'min interna mobil'),
        ('mobil_min_nat mobil_sms_nat', 'minute sms naional'),
        ('mobil_date', 'trafic date'),
    ])

    packages = []
    extraoptiuni = soup.select('div.extraoptiuniTabWrapper')
    for extraop in extraoptiuni:
        detail_url = extraop.select_one('div.prepaidButtons a')['href']
        abon_id = url_last_path(detail_url, scraper_url)

        abon_name = extraop.select_one('div.prepaidTabTitle strong').text
        abon_price = extraop.select_one('.prepaidPrice strong').text

        features = extraop.select('.prepaidTabDescription .ptd_OfferRow')
        features = [(feature.select_one('p').text,
                     feature.select_one('h4').text) for feature in features]
        characteristics = extract_features(features, feature_kw, abon_name)

        package = {
            'name': abon_name.strip(),
            'price': format_units(abon_price),
            'scraper_id_hint': abon_id.strip(),
            'characteristics': characteristics
        }
        packages.append(package)

    return json.dumps({"packages": packages})
Ejemplo n.º 2
0
def orange_abon(scraper_url: str):
    soup = get_soup(scraper_url)

    feature_kw = OrderedDict([
        ('mobil_min_nat mobil_sms_nat', 'minute sms naiona'),
        ('mobil_min_nat', 'minute naiona'),
        ('mobil_sms_nat', 'sms naiona'),
        ('mobil_min_internat', 'minute interna'),
        ('mobil_date', 'trafic internet'),
    ])

    abonamente = soup.select('.carusel-abo .item')
    packages = []
    for abon in abonamente:
        name = abon.select_one('.minbenbox.romico h3').text
        price = abon.select_one('.secbenbox .lefttext').text

        features = abon.select('.minbenbox.romico .minben')
        features = [(f.select_one('.descben').text.strip().lower(),
                     str(f.contents[0]).strip()) for f in features]
        characteristics = extract_features(features, feature_kw, name)

        packages.append({
            'name': name.strip(),
            'price': format_units(price),
            'characteristics': characteristics
        })

    return json.dumps({"packages": packages})
def images_features(image_paths, color):
    features = []
    for image_path in image_paths:
        image = cv2.imread(image_path)

        # extract features will convert from RGB to the desired color space
        image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)

        image_features = common.extract_features(image_rgb, color_space=color)

        features.append(image_features)
    return features
Ejemplo n.º 4
0
def find_cars(image, windows, color_space):
    car_seen_windows = []
    for window in windows:
        start = window[0]
        end = window[1]
        cropped_image = image[start[1]:end[1], start[0]:end[0]]

        if (cropped_image.shape[1] == cropped_image.shape[0]
                and cropped_image.shape[1] != 0):
            cropped_image = cv2.resize(cropped_image, (64, 64))
            features = common.extract_features(cropped_image, color_space)
            normalized_features = feature_scaler.transform([features])

            prediction = svc_classifier.predict(normalized_features)
            if (prediction == 1):
                car_seen_windows.append(window)

    return car_seen_windows
Ejemplo n.º 5
0
hist_feat = True
hog_feat = True

cars = glob.glob('vehicles/**/*.png')
noncars = glob.glob('non-vehicles/**/*.png')

print('Car images:', len(cars))
print('Non-Car images:', len(noncars))

t1 = time.time()
car_features = extract_features(cars,
                                cspace=color_space,
                                hist_feat=hist_feat,
                                hist_bins=hist_bins,
                                spatial_feat=spatial_feat,
                                spatial_size=spatial_size,
                                hog_feat=hog_feat,
                                orient=orient,
                                pix_per_cell=pix_per_cell,
                                cell_per_block=cell_per_block,
                                hog_channel=hog_channel)
notcar_features = extract_features(noncars,
                                   cspace=color_space,
                                   hist_feat=hist_feat,
                                   hist_bins=hist_bins,
                                   spatial_feat=spatial_feat,
                                   spatial_size=spatial_size,
                                   hog_feat=hog_feat,
                                   orient=orient,
                                   pix_per_cell=pix_per_cell,
                                   cell_per_block=cell_per_block,