Vote count: 0
I'm trying to iterate through whatever object my craigslist wrapper is returning. I'm using this:
so far I'm able to return the specific listings using this library, however it returns all of the information and I just want the name and price. here's what i got so far:
from craigslist import CraigslistForSale
item = CraigslistForSale(site='southjersey', category='fua', filters= {'max_price':200})
final = {}
for product in item.get_results(limit=5):
print product
and this is what returns
{'name': u'Large Desk', 'has_image': True, 'url': u'http://ift.tt/2lmKaie', 'has_map': True, 'price': u'$45', 'geotag': None, 'where': u'National Park', 'id': u'5994422173', 'datetime': u'2017-02-08 02:21'}
{'name': u'Huge Thick Glass Coffee Table', 'has_image': True, 'url': u'http://ift.tt/2iEmMQ4', 'has_map': True, 'price': u'$150', 'geotag': None, 'where': u'Cherry Hill, NJ', 'id': u'5965716025', 'datetime': u'2017-02-08 01:19'}
{'name': u'Large Mahogany Trimmed Mirror', 'has_image': True, 'url': u'http://ift.tt/2lmQ56V', 'has_map': True, 'price': u'$35', 'geotag': None, 'where': u'Cherry Hill, NJ', 'id': u'5978299633', 'datetime': u'2017-02-08 00:17'}
{'name': u'Vintage Wooden Accent Chair', 'has_image': True, 'url': u'http://ift.tt/2kuANfR', 'has_map': True, 'price': u'$50', 'geotag': None, 'where': u'Central Jersey', 'id': u'5975456218', 'datetime': u'2017-02-08 00:14'}
{'name': u'Wooden Desk/Accent Table', 'has_image': True, 'url': u'http://ift.tt/2lmM1U9', 'has_map': True, 'price': u'$125', 'geotag': None, 'where': u'South Jersey', 'id': u'5975455430', 'datetime': u'2017-02-08 00:14'}
just want the 'name', 'price' values. But what is object? Is this JSON or this a dictionary with all the values taken from the html?
asked 33 secs ago
craigslist wrapper return object python
Aucun commentaire:
Enregistrer un commentaire