Created
February 1, 2021 09:52
-
-
Save ThibaudLamothe/a224d114195ee817e8016668ab675e68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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