Last active
February 22, 2023 21:11
-
-
Save soup-bowl/0be367a20f9f5cc827a2a7a89f3224b3 to your computer and use it in GitHub Desktop.
Scrape RightMove
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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