Scraping

Using http requests and gathering information.

BeautifulSoup

Popular package for scraping html.

!pip install beautifulsoup4

Attributes to change in search

class query():
    def __init__(self) -> None:
        self.search_param = dict([x.split('=') for x in 'searchType=SALE&locationIdentifier=REGION%5E93941&insId=1&radius=0.0&minPrice=&maxPrice=&minBedrooms=&maxBedrooms=&displayPropertyType=&maxDaysSinceAdded=&_includeSSTC=on&sortByPriceDescending=&primaryDisplayPropertyType=&secondaryDisplayPropertyType=&oldDisplayPropertyType=&oldPrimaryDisplayPropertyType=&newHome=&auction=false'.split('&')])
        self.__repr__ = self.__str__
        
    def __str__(self) -> str:
        return "&".join(map(lambda x: x[0]+'='+x[1], self.search_param.items()))

str(query())
'searchType=SALE&locationIdentifier=REGION%5E93941&insId=1&radius=0.0&minPrice=&maxPrice=&minBedrooms=&maxBedrooms=&displayPropertyType=&maxDaysSinceAdded=&_includeSSTC=on&sortByPriceDescending=&primaryDisplayPropertyType=&secondaryDisplayPropertyType=&oldDisplayPropertyType=&oldPrimaryDisplayPropertyType=&newHome=&auction=false'
response = requests.get("https://www.rightmove.co.uk/property-for-sale/find.html?"+query().__str__())

page = BeautifulSoup(response.text, 'html.parser')
prices = page.findAll('div', attrs={'class':'propertyCard-priceValue'})
addrs = page.findAll('address', attrs={'class':"propertyCard-address property-card-updates", 'itemprop':"address"})

prices[0].getText().strip()
len(addrs)
0

back to top