mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
ADD: new provider for '1AImmobilien' / CHANGE: removing rootPath dependency, readme adjustments
This commit is contained in:
@@ -43,7 +43,9 @@ Adding new notification adapter is easy however. See [Contribution](https://gith
|
||||
|
||||
Configure the providers like described below. To disable a provider just remove its entry from the configuration or set it to `false`.
|
||||
|
||||
#### Ebay Kleinanzeigen, Immoscout, Immowelt, Immonet and Kalaydo
|
||||
#### Immoscout, Immonet and more
|
||||
|
||||
These are the current provider that are already implemented within _Fredy_
|
||||
|
||||
```json
|
||||
"kleinanzeigen": {
|
||||
@@ -66,6 +68,10 @@ Configure the providers like described below. To disable a provider just remove
|
||||
"url": "http://www.kalaydo.de/...",
|
||||
"enabled": true
|
||||
},
|
||||
"einsAImmobilien": {
|
||||
"url": "https://www.1a-immobilienmarkt.de/...",
|
||||
"enabled": true
|
||||
}
|
||||
```
|
||||
|
||||
Go to the respective provider page and create your custom search queries by
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
"kalaydo": {
|
||||
"url": "https://www.kalaydo.de/...",
|
||||
"enabled": true
|
||||
},
|
||||
"einsAImmobilien":{
|
||||
"url": "https://www.1a-immobilienmarkt.de/...",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"blacklist": [
|
||||
|
||||
@@ -32,6 +32,10 @@
|
||||
"kalaydo": {
|
||||
"url": "https://www.kalaydo.de/immobilien/eigentumswohnung-kaufen/o/duesseldorf/4/",
|
||||
"enabled": true
|
||||
},
|
||||
"einsAImmobilien":{
|
||||
"url": "https://www.1a-immobilienmarkt.de/suchen/duesseldorf/wohnung-kaufen.html?search=yes&cfid=98b39c7e-b403-4764-8f3c-57bf590923d0&data_hash=fcfa4ee1e6cfaf791051a6f342eec1f8&sort_type=newest",
|
||||
"enabled": true
|
||||
}
|
||||
},
|
||||
"blacklist": [
|
||||
|
||||
3
index.js
3
index.js
@@ -1,8 +1,7 @@
|
||||
require('rootpath')();
|
||||
const fs = require('fs');
|
||||
const path = './lib/provider';
|
||||
const sources = fs.readdirSync(path);
|
||||
const config = require('conf/config.json');
|
||||
const config = require('./conf/config.json');
|
||||
const stats = require('./lib/services/stats');
|
||||
|
||||
setInterval(
|
||||
|
||||
37
lib/provider/einsAImmobilien.js
Executable file
37
lib/provider/einsAImmobilien.js
Executable file
@@ -0,0 +1,37 @@
|
||||
const config = require('../../conf/config.json');
|
||||
const Fredy = require('../fredy');
|
||||
const utils = require('../utils');
|
||||
|
||||
function normalize(o) {
|
||||
const size = `${o.size.replace(' Wohnfläche ', '').trim()} / ${o.rooms.trim()}`;
|
||||
const link = `https://www.1a-immobilienmarkt.de/expose/13691814${o.id}.html`
|
||||
|
||||
return Object.assign(o, { size, link });
|
||||
}
|
||||
|
||||
function applyBlacklist(o) {
|
||||
const titleNotBlacklisted = !utils.isOneOf(o.title, config.blacklist);
|
||||
const descNotBlacklisted = !utils.isOneOf(o.description, config.blacklist);
|
||||
|
||||
return titleNotBlacklisted && descNotBlacklisted;
|
||||
}
|
||||
|
||||
const einsAImmobilien = {
|
||||
name: 'einsAImmobilien',
|
||||
enabled: config.sources.einsAImmobilien.enabled,
|
||||
url: config.sources.einsAImmobilien.url,
|
||||
crawlContainer: '.tabelle',
|
||||
crawlFields: {
|
||||
id: '.inner_object_data input[name="marker_objekt_id"]@value | int',
|
||||
price: '.tabelle .inner_object_data .single_data_price | removeNewline | trim',
|
||||
size: '.tabelle .inner_object_data .data_boxes div:nth-child(1)',
|
||||
rooms: '.tabelle .inner_object_data .data_boxes div:nth-child(2)',
|
||||
title: '.tabelle .inner_object_data .tabelle_inhalt_titel_black | removeNewline | trim',
|
||||
description: '.tabelle .inner_object_data .objekt_beschreibung | removeNewline | trim'
|
||||
},
|
||||
paginate: '.pagination_blocks div:last a@href',
|
||||
normalize: normalize,
|
||||
filter: applyBlacklist
|
||||
};
|
||||
|
||||
module.exports = new Fredy(einsAImmobilien);
|
||||
@@ -32,7 +32,6 @@
|
||||
"lowdb": "^1.0.0",
|
||||
"mocha": "^4.1.0",
|
||||
"request-x-ray": "^0.1.4",
|
||||
"rootpath": "^0.1.2",
|
||||
"slack": "^10.0.0",
|
||||
"x-ray": "^2.3.2"
|
||||
},
|
||||
|
||||
49
test/einsAImmobilien.test.js
Normal file
49
test/einsAImmobilien.test.js
Normal file
@@ -0,0 +1,49 @@
|
||||
const mockNotification = require('./mocks/mockNotification');
|
||||
const mockConfig = require('../conf/config.test');
|
||||
const mockStore = require('./mocks/mockStore');
|
||||
const mockStats = require('./mocks/mockStats');
|
||||
const proxyquire = require('proxyquire').noCallThru();
|
||||
const expect = require('chai').expect;
|
||||
|
||||
describe('#einsAImmobilien testsuite()', () => {
|
||||
|
||||
const einsAImmobilien = proxyquire('../lib/provider/einsAImmobilien', {
|
||||
'../../conf/config.json': mockConfig,
|
||||
'../lib/fredy': proxyquire('../lib/fredy', {
|
||||
'./services/store': mockStore,
|
||||
'./notification/notify': mockNotification
|
||||
})
|
||||
});
|
||||
|
||||
it('should test einsAImmobilien provider', async () => {
|
||||
return await new Promise(resolve => {
|
||||
einsAImmobilien.run(mockStats).then(() => {
|
||||
const immonetDbContent = einsAImmobilien._getStore()._db;
|
||||
|
||||
expect(immonetDbContent.einsAImmobilien).to.be.a('array');
|
||||
|
||||
// const notificationObj = mockNotification.get();
|
||||
// expect(notificationObj).to.be.a('object');
|
||||
// expect(notificationObj.serviceName).to.equal('einsAImmobilien');
|
||||
//
|
||||
// /** check the actual structure **/
|
||||
// expect(notificationObj.payload.id).to.be.a('number');
|
||||
// expect(notificationObj.payload.price).to.be.a('string');
|
||||
// expect(notificationObj.payload.size).to.be.a('string');
|
||||
// expect(notificationObj.payload.title).to.be.a('string');
|
||||
// expect(notificationObj.payload.link).to.be.a('string');
|
||||
// expect(notificationObj.payload.address).to.be.a('string');
|
||||
//
|
||||
// /** check the values if possible **/
|
||||
// expect(notificationObj.payload.id).to.equal(immonetDbContent.immonet[immonetDbContent.immonet.length - 1]);
|
||||
// expect(notificationObj.payload.price).that.does.include('€');
|
||||
// expect(notificationObj.payload.size).that.does.include('m²');
|
||||
// expect(notificationObj.payload.title).to.be.not.empty;
|
||||
// expect(notificationObj.payload.link).that.does.include('https://www.immonet.de');
|
||||
// expect(notificationObj.payload.address).to.be.not.empty;
|
||||
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user