Rightmove Postcode to ID

Viewed 157
1 Answers

I'm not aware of Api, but you can use different URL (with postcode) to obtain the Location Id. For example:

import json
import requests


# add postcode here:
l = "https://www.rightmove.co.uk/house-prices/sy3-9eb.html"


html_text = requests.get(l).text
data = re.search(r"__PRELOADED_STATE__ = ({.*?})<", html_text)
data = json.loads(data.group(1))

# print(json.dumps(data, indent=4))

location_id = data["searchLocation"]["locationId"]
final_link = "https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=POSTCODE^{}".format(
    location_id
)

print(final_link)

Prints:

https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=POSTCODE^4203018
Related