Created
April 24, 2020 10:35
-
-
Save ShayanRiyaz/461019b3da553703bb022d38fd25f87b 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
url = requests.get('https://www.rentcafe.com/average-rent-market-trends/us/ca/los-angeles/').text | |
soup = BeautifulSoup(url,"html.parser") | |
table = soup.find('table',id="MarketTrendsAverageRentTable") | |
pr = table.find_all('td') | |
nh = table.find_all('th') | |
price = [] | |
neighbourhood = [] | |
for i in range(0, len(pr)): | |
price.append(pr[i].text.strip()) | |
neighbourhood.append(nh[i+2].text.strip()) | |
df_rent = pd.DataFrame(data=[neighbourhood, price]).transpose() | |
df_rent.columns = ['Neighbourhood', nh[1].text] | |
df_rent[(df_rent['Neighbourhood']=='Harvard Heights') | (df_rent['Neighbourhood']=='Korea Town')] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment