Skip to content

Instantly share code, notes, and snippets.

@ThibaudLamothe
Created February 1, 2021 09:52
Show Gist options
  • Save ThibaudLamothe/a224d114195ee817e8016668ab675e68 to your computer and use it in GitHub Desktop.
Save ThibaudLamothe/a224d114195ee817e8016668ab675e68 to your computer and use it in GitHub Desktop.
def prepare_request(city, checkin=None, checkout=None, price_min=None, price_max=None, currency='USD'):
""" Given a city and eventual dates, and eventual prices, returns the airbnb url to scrap
Both dates must be strings formatted 'YYYY-MM-DD'
"""
url = f'https://www.airbnb.com/s/{city}/homes/?'
if checkin and checkout:
url += f'&checkin={checkin}&checkout={checkout}'
if price_min and price_max:
url+= f'&price_min={price_min}&price_max={price_max}&display_currency={currency}'
return url
url = prepare_request('toronto', '2021-03-01', '2021-03-08', 100, 110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment