├── .gitignore ├── README.md ├── example.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | outcodeData.json 2 | allData.json 3 | 4 | 5 | # Logs 6 | logs 7 | *.log 8 | npm-debug.log* 9 | 10 | # Runtime data 11 | pids 12 | *.pid 13 | *.seed 14 | *.pid.lock 15 | 16 | # Directory for instrumented libs generated by jscoverage/JSCover 17 | lib-cov 18 | 19 | # Coverage directory used by tools like istanbul 20 | coverage 21 | 22 | # nyc test coverage 23 | .nyc_output 24 | 25 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 26 | .grunt 27 | 28 | # node-waf configuration 29 | .lock-wscript 30 | 31 | # Compiled binary addons (http://nodejs.org/api/addons.html) 32 | build/Release 33 | 34 | # Dependency directories 35 | node_modules 36 | jspm_packages 37 | 38 | # Optional npm cache directory 39 | .npm 40 | 41 | # Optional eslint cache 42 | .eslintcache 43 | 44 | # Optional REPL history 45 | .node_repl_history 46 | 47 | # Output of 'npm pack' 48 | *.tgz 49 | 50 | # Yarn Integrity file 51 | .yarn-integrity 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rightmove Scraper 2 | ![Safe NPM](https://safenpm.herokuapp.com/status/rightmove-scraper.png) 3 | 4 | ## Usage: 5 | ```bash 6 | npm i --save rightmove-scraper 7 | ``` 8 | ```javascript 9 | const outcodeData = require('./outcodeData.json'); //See https://github.com/ISNIT0/rightmove-outcode-scraper 10 | const rightmoveApi = require('rightmove-scraper')(outcodeData); 11 | 12 | rightmoveApi 13 | .byOutcode('SW10') 14 | .then(data => console.log(data)); 15 | 16 | rightmoveApi 17 | .propertyDetail(63605453) 18 | .then(data => console.log(data)); 19 | ``` 20 | 21 | ## Requirements: 22 | You will need outcodeData.json from https://github.com/ISNIT0/rightmove-outcode-scraper. 23 | 24 | ## Motivation: 25 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | const rightmoveApi = require('./index.js')([{ code: 1081, outcode: 'HP13' }]); 2 | 3 | rightmoveApi 4 | .byOutcode('SW10') 5 | .then(data => console.log(data)); 6 | 7 | rightmoveApi 8 | .propertyDetail(63605453) 9 | .then(data => console.log(data)); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const request = require('request-promise-native'); 3 | 4 | const makeReq = function makeReq(reqGenerator) { 5 | return function (...args) { 6 | return new Promise(function (resolve, reject) { 7 | let req; 8 | try { 9 | req = reqGenerator(...args); 10 | } catch (e) { 11 | reject(e); 12 | } 13 | 14 | request(req) 15 | .then(function (res) { 16 | try { 17 | resolve(JSON.parse(res)) 18 | } catch (e) { 19 | reject(e); 20 | } 21 | }) 22 | .catch(reject); 23 | }); 24 | }; 25 | } 26 | 27 | module.exports = function (outcodeData) { 28 | outcodeData = outcodeData.reduce((acc, val) => { 29 | acc[val.outcode] = val.code; 30 | return acc; 31 | }, {}); 32 | return { 33 | byOutcode: makeReq(function (outcode) { 34 | if (typeof outcode !== 'string') throw new Error(`byOutcode was expecting a string, but got ${outcode} (${typeof outcode})`); 35 | outcode = outcode.toUpperCase().trim(); 36 | const locIdent = outcodeData[outcode]; 37 | if (!locIdent) throw new Error(`byOutcode could not find the outcode specified (${outcode}), either the value is invalid, or your outcodeData.json file is out of date.`); 38 | return `http://api.rightmove.co.uk/api/sale/find?index=0&sortType=2&numberOfPropertiesRequested=1000&locationIdentifier=OUTCODE%5E${locIdent}&apiApplication=IPAD`; 39 | }), 40 | propertyDetail: makeReq(function (propertyId) { 41 | if (!propertyId) throw new Error(`expecting propertyId, but got ${propertyId}`); 42 | return `http://api.rightmove.co.uk/api/propertyDetails?propertyId=${propertyId}&apiApplication=IPAD`; 43 | }) 44 | }; 45 | }; 46 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rightmove-scraper", 3 | "version": "1.0.3", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "request": "^2.79.0", 13 | "request-promise-native": "^1.0.3" 14 | }, 15 | "tonicExampleFilename":"example.js" 16 | } 17 | --------------------------------------------------------------------------------