I am using Python to scrape some data from Rightmove. At the moment, I'm having to look up the rightmove postcode ID manually to generate the URL. Is there a way of doing this via the API?
For example, for postcode SY3 9EB, the URL is: https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=POSTCODE%5E4203018
So I need a way of mapping a table of postcodes to ID, e.g.
Postcode ID
SY3 9EB 5E4203018
Thanks in advance!
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With