Example #1
0
    res = requests.get(urlstring)
    soup = bs4.BeautifulSoup(res.text, 'lxml')

    span = soup.find_all('span', {'class': 'actual-price'})
    vehicles = soup.find_all('li', {'class': 'vehicle'})

for i in vehicles:
    Car_Price = CleanUp_Car_Price(
        str(i.find_all('span', {'class': 'actual-price'})[0]))
    Car_info_tab = i.find_all('div', {'class': 'small-7 columns'})
    first_thing = Car_info_tab[0]
    Car_Make = CleanUp_Car_Name(str(first_thing.select('h3')[0])).replace(
        ' ', '_')

    Ref = str(i.find_all('div', {'class': 'ref-views'})[0])[36:43]
    Car_Age_Milage = CleanUp_Notes(str(first_thing.select('p')[1]))
    Year = Car_Age_Milage[0]
    Mileage = Car_Age_Milage[1]

    print('Reff:', Ref)
    print('Car Price:', Car_Price)
    print('Car Make:', Car_Make)
    print('Year:', Year)
    print('Mileage:', Mileage)

    #Car_Age_Milage, is notes.
    ## Put this stuff in a db

    conn = sqlite3.connect('Cars.db')
    cursor = conn.cursor()
Example #2
0
def test_CleanUp_Notes():
    list = CleanUp_Notes(
        '<p>MPV, Manual, Petrol, Grey, 2011 (11), 53,104 miles</p>')

    assert list[0] == 2011
    assert list[1] == 53104