Skip to content

Need helps on how to build a pandas dataframe including these items from listing. #142

Answered by sdfordham
Mark00353 asked this question in Q&A
Discussion options

You must be logged in to vote

If you want something openable with excel, then use the csv package from the standard library. Make sure to open with encoding='utf-8' or the euro symbol will get mangled.

import csv
from daftlistings import Daft, Location, SearchType, PropertyType

daft = Daft()
daft.set_location(Location.DUBLIN)
daft.set_search_type(SearchType.RESIDENTIAL_RENT)
daft.set_property_type(PropertyType.APARTMENT)
daft.set_max_price(700)

listings = daft.search()

with open('./listings.csv', 'w', newline='', encoding='utf-8') as F:
    writer = csv.writer(F)
    writer.writerow(['title', 'price', 'link']) # Column names
    for listing in listings:
        writer.writerow([listing.title, listing.price, listing.d…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Mark00353
Comment options

Answer selected by Mark00353
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants