Skip to content

Instantly share code, notes, and snippets.

@soup-bowl
Last active February 22, 2023 21:11
Show Gist options
  • Save soup-bowl/0be367a20f9f5cc827a2a7a89f3224b3 to your computer and use it in GitHub Desktop.
Save soup-bowl/0be367a20f9f5cc827a2a7a89f3224b3 to your computer and use it in GitHub Desktop.
Scrape RightMove
import urllib3
from lxml import html
http = urllib3.PoolManager()
r = http.request('GET', 'https://www.rightmove.co.uk/properties/<ID>')
if r.status == 200:
content = html.fromstring(r.data.decode('utf-8'))
scripts = content.xpath('//script')
for script in scripts:
contents = html.tostring(script).decode('utf-8')
if "propertyData" in contents:
ejson = contents.split('{', 1)[1].removesuffix('\n</script>\n\n')
print('{' + ejson)
exit(0)
exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment