Skip to content

Instantly share code, notes, and snippets.

@Sam-Martin
Created February 27, 2019 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sam-Martin/6132f979ee9b83310a44a6cbccf4c5e8 to your computer and use it in GitHub Desktop.
Save Sam-Martin/6132f979ee9b83310a44a6cbccf4c5e8 to your computer and use it in GitHub Desktop.
Scrape Rightmove
import json
from bson import json_util # pip install pymongo
from datetime import datetime
from rightmove_webscraper import rightmove_data
class rightmove_list(list):
def __init__(self, rightmove_object_results):
new_list = []
for key in rightmove_object_results.keys():
if not new_list:
new_list = [{} for x in rightmove_object_results[key]]
for i, v in enumerate(rightmove_object_results[key]):
new_list[i][key] = self.__fix_datetime(v)
super().__init__(new_list)
def __fix_datetime(self, val):
if isinstance(val,datetime):
return val.strftime('%Y-%m-%dT%H:%M:%S.%f')
return val
url = "https://www.rightmove.co.uk/property-for-sale/find.html?locationIdentifier=REGION%5E85329&minBedrooms=2&maxPrice=450000&radius=0.25&sortType=6&includeSSTC=false"
rightmove_object = rightmove_data(url)
# print(rightmove_object.get_results.to_json())
print(json.dumps(rightmove_list(rightmove_object.get_results)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment