Skip to main content

Simple Craigslist wrapper.

Project description

A simple Craigslist wrapper.

License: MIT-Zero.

Disclaimer

  • I don’t work for or have any affiliation with Craigslist.

  • This module was implemented for educational purposes. It should not be used for crawling or downloading data from Craigslist.

Installation

pip install python-craigslist

Classes

Base class:

  • CraigslistBase

Subclasses:

  • CraigslistCommunity (craigslist.org > community)

  • CraigslistHousing (craigslist.org > housing)

  • CraigslistJobs (craigslist.org > jobs)

  • CraigslistPersonals (craigslist.org > personals)

  • CraigslistForSale (craigslist.org > for sale)

  • CraigslistEvents (craigslist.org > event calendar)

  • CraigslistServices (craigslist.org > services)

  • CraigslistGigs (craigslist.org > gigs)

  • CraigslistResumes (craigslist.org > resumes)

Usage

Every subclass has its own set of filters. To get a list of all the filters supported by a specific subclass, use the .show_filters() class-method:

>>> from craigslist import CraigslistJobs, CraigslistForSale
>>> CraigslistJobs.show_filters()

Base filters:
* posted_today = True/False
* query = ...
* search_titles = True/False
* has_image = True/False
Section specific filters:
* is_internship = True/False
* is_telecommuting = True/False
* is_contract = True/False
* is_parttime = True/False
* is_nonprofit = True/False
* employment_type = u'full-time', u'part-time', u'contract', u"employee's choice"

>>> CraigslistForSale.show_filters(category='cta')

Base filters:
* posted_today = True/False
* query = ...
* search_titles = True/False
* has_image = True/False
Section specific filters:
* min_year = ...
* model = ...
* min_price = ...
* max_miles = ...
* make = ...
* max_price = ...
* min_miles = ...
* max_year = ...
* auto_title_status = u'clean', u'salvage', u'rebuilt', u'parts only', u'lien', u'missing'
* auto_transmission = u'manual', u'automatic', u'other'
* auto_fuel_type = u'gas', u'diesel', u'hybrid', u'electric', u'other'
* auto_paint = u'black', u'blue', u'brown', u'green', u'grey', u'orange', u'purple', u'red', u'silver', u'white', u'yellow', u'custom'
* auto_bodytype = u'bus', u'convertible', u'coupe', u'hatchback', u'mini-van', u'offroad', u'pickup', u'sedan', u'truck', u'SUV', u'wagon', u'van', u'other'
* auto_drivetrain = u'fwd', u'rwd', u'4wd'
* auto_size = u'compact', u'full-size', u'mid-size', u'sub-compact'
* auto_cylinders = u'3 cylinders', u'4 cylinders', u'5 cylinders', u'6 cylinders', u'8 cylinders', u'10 cylinders', u'12 cylinders', u'other'
* condition = u'new', u'like new', u'excellent', u'good', u'fair', u'salvage'

Examples

Looking for a room in San Francisco?

from craigslist import CraigslistHousing
cl_h = CraigslistHousing(site='sfbay', area='sfc', category='roo',
                         filters={'max_price': 1200, 'private_room': True})

for result in cl_h.get_results(sort_by='newest', geotagged=True):
    print result

{
    'id': u'4851150747',
    'name': u'Near SFSU, UCSF and NEWLY FURNISHED - CLEAN, CONVENIENT and CLEAN!',
    'url': u'http://sfbay.craigslist.org/sfc/roo/4851150747.html',
    'datetime': u'2015-01-27 23:44',
    'price': u'$1100',
    'where': u'inner sunset / UCSF',
    'has_image': False,
    'has_map': True,
    'geotag': (37.738473, -122.494721)
}
# ...

Maybe an engineering internship in Silicon Valley?

from craigslist import CraigslistJobs
cl_j = CraigslistJobs(site='sfbay', area='sby', category='eng',
                      filters={'is_internship': True, 'employment_type': ['full-time', 'part-time']})

for result in cl_j.get_results():
    print result

{
    'id': u'5708651182',
    'name': u'GAME DEVELOPER INTERNSHIP AT TYNKER - AVAILABLE NOW!',
    'url': u'http://sfbay.craigslist.org/pen/eng/5708651182.html',
    'datetime': u'2016-07-30 13:30',
    'price': None,
    'where': u'mountain view',
    'has_image': True,
    'has_map': True,
    'geotag': None
}
# ...

Events with free food in New York?

from craigslist import CraigslistEvents
cl_e = CraigslistEvents(site='newyork', filters={'free': True, 'food': True})

for result in cl_e.get_results(sort_by='newest', limit=5):
    print result

{
    'id': u'4866178242',
    'name': u'Lituation Thursdays @ Le Reve',
    'url': u'http://newyork.craigslist.org/mnh/eve/4866178242.html',
    'datetime': u'1/29',
    'price': None,
    'where': u'Midtown East',
    'has_image': True,
    'has_map': True,
    'geotag': None
}
# ...

Support

If you find any bug or you want to propose a new feature, please use the issues tracker. I’ll be happy to help you! :-)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-craigslist-1.0.5.tar.gz (14.7 kB view details)

Uploaded Source

File details

Details for the file python-craigslist-1.0.5.tar.gz.

File metadata

File hashes

Hashes for python-craigslist-1.0.5.tar.gz
Algorithm Hash digest
SHA256 f832ac96e5f15097edc0c4be79b7446c985454ed9f5e76444c2a97b6893444c7
MD5 5c469471f671982d92be9c7158504f7f
BLAKE2b-256 ae86638f59becb44721f487fecc99df50c6030ed3a17625e6d7ce47d7acf9055

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page