Created
August 30, 2022 19:36
-
-
Save joshreini1/c8d84a0a5ceffa4dd6626b35f8e9dc10 to your computer and use it in GitHub Desktop.
Get AirBnb Data
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
import requests | |
import pandas as pd | |
def get_airbnb_data(city): | |
#input city with + instead of spaces, e.g. "San+Francisco" | |
#note: open data soft caps requests at 10,000 | |
url = "https://public.opendatasoft.com/api/records/1.0/search/?dataset=airbnb-listings&q=&rows=10000&refine.city=" + city | |
resp = requests.get(url) | |
print(resp.status_code) | |
data = resp.json() | |
abnb_df = pd.DataFrame([flatten_json(x,exclude='datasetid') for x in data['records']]) | |
return abnb_df |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment