Using Python to Find Myself A Rental Home

Now that is done, we just have to repeat the same process of finding the element which contains the Price and Size information, and to extract that as well by adjusting the code in Figure 2.That was page one of the iProperty search page, which showed me 10 apartments..I would need a lot more than that to perform a proper comparison..In this post, I would choose to extract data from 5 pages of search results, giving myself a pool of apartments to choose from..How can that be done?.Luckily for me, the URL of iProperty is fairly simple:https://www.iproperty.com.sg/rent/district-20/hdb/?bedroom=3&page=1As you can see, it only contains three parts: the district, number of bedrooms, and the page number..That makes life a lot easier, as I can now just loop through pages 1:5..In between each loop, I also planted a time.sleep function, just to let my web scraper behave sort of human-like and prevent myself from being blocked from the website.With that, I now have a reasonably sized pool of apartments with three variables: Price, Address, and Size..After combining them into one data frame using pandas (noting also that there is no error showing that the number of rows are different implying that each unit displayed would have an address, price, and size), I would now need to clean the data..Let us have a look at the first five rows of the dataset.Figure 4: First five rows of the full data setRight of the bat, you can see that there are various aspects of the data that would need to be adjusted..For one, I want the Price and Size column to be numeric..Hence ‘SGD’, ‘Built-up :’ and ‘,’ has got to go..Also, upon closer inspection for the size column, there are several units that are denoted in ‘sq.. More details

Leave a Reply