Python 3: python-craigslist

Use Craigslist Wrapper to Search for Available Rooms

nick3499
2 min readJan 2, 2018

Module: python-craigslist

python-craigslist package is available in Python package index:

$ pip install python-craigslist

Script: craigslist_rooms.py

To run the Python script, in a Unix-like CLI, enter the following:

$ python3 craigslist_rooms.py

The script iterates through filtered results to return the following:

ID:       6437914867
Name: Large Room in Historic Home
URL: https://chicago.craigslist.org/wcl/roo/d/large-room-in-historic-home/6437914867.html
Date: 2018-01-01 19:25
Price: $800
Where: Western Suburbs
Geotag: None
Bedrooms: None
————————————————————
ID: 6444647630
Name: 5 bedroom $366 for rent utilities not included
URL: https://chicago.craigslist.org/wcl/roo/d/5-bedroom-366-for-rent/6444647630.html
Date: 2018-01-01 18:08
Price: $366
Where: dekalb
Geotag: (41.926905, -88.747579)
Bedrooms: None
————————————————————
ID: 6444643060
Name: room for rent willowbrook
URL: https://chicago.craigslist.org/wcl/roo/d/room-for-rent-willowbrook/6444643060.html
Date: 2018-01-01 17:19
Price: $630
Where: willowbrook
Geotag: (41.74838, -87.947187)
Bedrooms: None
————————————————————
ID: 6444623021
Name: Private Room for rent w/ bathroom, western suburbs. Hinsdale
URL: https://chicago.craigslist.org/wcl/roo/d/private-room-for-rent/6444623021.html
Date: 2018-01-01 16:56
Price: $750
Where: Hinsdale
Geotag: None
Bedrooms: None
————————————————————
ID: 6444620370
Name: Beautiful townhome private room for rent
URL: https://chicago.craigslist.org/wcl/roo/d/beautiful-townhome-private/6444620370.html
Date: 2018-01-01 16:53
Price: $750
Where: Hinsdale
Geotag: (41.8001, -87.9287)
Bedrooms: None
————————————————————

Subclass: CraigslistHousing

CraigslistHousing subclass has a unique set of filter parameters.

  • site = 'chicago' specifies chicago.craigslist.org subdomain
  • area = 'wcl' specifies west chicagoland subdirectory or search/wcl
  • category = 'roo' specifies rooms & shares subdirectory or search/wcl/roo

i.get_results() method returns one dict() per result:

{'id': '6432801865', 'name': 'Room /share wanted $680 Bensenville Area.', 'url': 'https://chicago.craigslist.org/wcl/roo/d/room-share-wanted-680/6432801865.html', 'datetime': '2017-12-26 09:36', 'price': '$680', 'where': 'Bensenville', 'has_image': False, 'has_map': True, 'geotag': None, 'bedrooms': None, 'area': None}

i['id'] returns '6432801865'

--

--

nick3499
nick3499

Written by nick3499

coder of JavaScript and Python

No responses yet