juliomalegria / python-craigslist

Simple Craigslist wrapper
MIT No Attribution
387 stars 117 forks source link

Using multiple sites #48

Closed rebelhazzard closed 6 years ago

rebelhazzard commented 6 years ago

cl_h = CraigslistForSale(site='vancouver', 'toronto' area='', category='cto',

I want to be able to use multiple sites like the above, instead of just searching vancouver I want to be able to search toronto too.

how can i do this?

thanks

ramgarden commented 6 years ago

Looking in the code it looks like there's currently no way to tell it to search all sites. You'd just have to call it twice and display the results for each.

juliomalegria commented 6 years ago

This will have to make 2 calls to 2 different URLs, so I think is more transparent to instantiate two objects and call get_results twice. You could then chain the generators returned like so:

import itertools

cl_vancouver = CraigslistForSale(site='vancouver', ...)
cl_toronto = CraigslistForSale(site='toronto', ...)
for results in itertools.chain(cl_vancouver.get_results(), cl_toronto.get_results()):
    print result