Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()

    parser.add_argument("-c",
                        "--carGurus",
                        help='Scrape from cargurus.com',
                        action='store_false')
    parser.add_argument("-t",
                        "--trueCar",
                        help="Scrape from truecar.com",
                        action='store_true')
    parser.add_argument("-e",
                        "--edmunds",
                        help="Scrape from edmunds.com",
                        action='store_true')

    args = parser.parse_args()

    if args.trueCar:
        for make_model, url in URL_list['truecar'].items():
            carlistings = TrueCar(make_model, url[0], url[1])
            carlistings.fetch_all_pages()
            carlistings.parse_all()
    elif args.edmunds:
        for make_model, url in URL_list['edmunds'].items():
            carlistings = Edmunds(make_model, url[0], url[1])
            carlistings.fetch_all_pages()
            carlistings.parse_all()
    else:
        for make_model, url in URL_list['carguru'].items():
            carlistings = CarGurus(make_model, url[0], url[1])
            carlistings.fetch_all_pages()
            carlistings.parse_all()
Ejemplo n.º 2
0
"""
Edmunds.com API Python wrapper - Tests
Edmunds API Documentation: http://developer.edmunds.com/

author: Michael Bock <*****@*****.**>
"""

from edmunds import Edmunds

api = Edmunds('YOUR API KEY')

# Test 1: No URL Path
assert api.make_call('') is None

# Test 2: Incorrect URL Path
assert api.make_call('ERROR') is None

# Test 3: Correct URL Path
# Check that makesCount key is in response
assert 'makesCount' in api.make_call('/api/vehicle/v2/makes/count')

print("All tests passed!")
Ejemplo n.º 3
0
	:param view: 'basic' or 'full'; optional, default is basic
	:type view: str
	:returns: Makes as described here: http://developer.edmunds.com/api-documentation/vehicle/spec_make/v2/01_list_of_makes/api-response.html
	:rtype: JSON object
	"""
    endpoint = '/api/vehicle/v2/makes'
    options = {}
    if year:
        options['year'] = year
    if state:
        options['state'] = state
    if view:
        options['view'] = view

    response = api.make_call(endpoint, **options)

    # error checking
    if (not response or 'errorType' in response or 'error' in response):
        print "Error in get_makes"
        if 'errorType' in response:
            print "errorType: " + response['errorType']
        if 'message' in response:
            print "message: " + response['message']
        return None

    return response


if __name__ == "__main__":
    api = Edmunds('YOUR API KEY', True)  # True indicates debug mode is ON
    print get_makes(api, '2013', 'new')
"""
Edmunds.com API Python wrapper - Car Market Value Lookup
Edmunds API Documentation: http://developer.edmunds.com/

author: Jon Fairbanks <*****@*****.**>
"""

from edmunds import Edmunds
import json, ast, os
api = Edmunds('api_key')

cls = lambda: os.system('cls')

# Gather car details (NEW)
cls()
year = raw_input("What year is the car?: ")
make = raw_input("What make?: ")
model = raw_input("Model?: ")
mileage = raw_input("And approx. how many miles?: ")
proper_desc = year + ' ' + make + ' ' + model + ' w/ ' + mileage + ' mi.'

# Make the API call for styleID
id_endpoint = '/api/vehicle/v2/' + make + '/' + model + '/' + year + '/styles'
json_response = api.make_call(id_endpoint)

# Gather style ID details from Edmunds
styleID = json_response['styles'][0]['id']
styleID = str(styleID)
zip = '68138'

# Make the API call for current rough market value