Compare commits

..

4 Commits
5.2.0 ... 5.3.0

Author SHA1 Message Date
Christian Kellner
ec986e4b18 adding comma separation for MailJet & Sendgrid | fixing immowelt | upgrading dependencies (#34) 2021-10-06 10:45:13 +02:00
orangecoding
8d93581dfc do not send notifications when listings have been filtered 2021-07-05 12:01:14 +02:00
Christian Kellner
b65c5d1a0c Update README.md 2021-07-01 14:26:56 +02:00
Christian Kellner
57d295e882 Update README.md 2021-06-28 14:51:23 +02:00
12 changed files with 836 additions and 540 deletions

View File

@@ -1,3 +1,8 @@
###### [V5.3.0]
- Upgrading dependencies
- It's now possible to send mails to multiple receiver using comma separation for MailJet & Sendgrid
- Fixing Immowelt scraping
###### [V5.2.0]
- Upgrading dependencies
- Adding new similarity check layer (Duplicates are being removed now)

View File

@@ -2,9 +2,11 @@
[![Build Status](https://travis-ci.org/orangecoding/fredy.svg?branch=master)](https://travis-ci.org/orangecoding/fredy)
_Fredy_ scrapes multiple services (Immonet, Immowelt etc.) as often as you want and send new listings to you once they appear. The list of available services can easily be extended. For your convenience, a ui helps you to configure your search jobs.
Searching an apartment in Germany can be quite frustrating. Not any longer as Fredy will take over and only notifies you once new listings have been found that matches your requirements.
If _Fredy_ found matching results, it will send them to you via Slack, Email, Telegram etc. (More adapter possible.) As _Fredy_ will store the listings it found, new results will not be sent twice (and as a side-effect, _Fredy_ can show some statistics..)
_Fredy_ scrapes multiple services (Immonet, Immowelt etc.) and send new listings to you once they appear. The list of available services can easily be extended. For your convenience, a ui helps you to configure your search jobs.
If _Fredy_ found matching results, it will send them to you via Slack, Email, Telegram etc. (More adapter possible.) As _Fredy_ will store the listings it has found, new results will not be sent twice (and as a side-effect, _Fredy_ can show some statistics..). Furthermore, _Fredy_ checks duplicates per scraping so that the same listings are not being sent when posted on various platforms. (Happens more often than one might think)
## Usage
@@ -15,7 +17,7 @@ yarn (or npm install)
yarn run prod
yarn run start
```
_Fredy_ will start with the default port, set to `9998`. You can access _Fredy_ by opening a browser `http://localhost:9998`. The default login is `admin` for username and password. (You should change the password asap when you plan to run Fredy on your server.)
_Fredy_ will start with the default port, set to `9998`. You can access _Fredy_ by opening a browser `http://localhost:9998`. The default login is `admin` both for username and password. (You should change the password asap when you plan to run Fredy on your server.)
<p align="center">
<img alt="Job Configuration" src="https://github.com/orangecoding/fredy/blob/master/doc/screenshot__1.png" width="30%">
@@ -29,7 +31,7 @@ _Fredy_ will start with the default port, set to `9998`. You can access _Fredy_
</p>
## Immoscout
I have added **EXPERIMENTAL** support for Immoscout. Immoscout is somewhat special, coz they have decided to secure their service from bots using Re-Capture. Finding a way around this is barely possible. For _Fredy_ to be able to bypass the check, I'm using a service called [ScrapingAnt](https://scrapingant.com/). The trick is to use a headless browser, rotating proxies and (once successful validated) re-send the cookies each time.
I have added **experimental** support for Immoscout. Immoscout is somewhat special, coz they have decided to secure their service from bots using Re-Capture. Finding a way around this is barely possible. For _Fredy_ to be able to bypass the check, I'm using a service called [ScrapingAnt](https://scrapingant.com/). The trick is to use a headless browser, rotating proxies and (once successful validated) re-send the cookies each time.
To be able to use Immoscout, you need to create an account at ScrapingAnt. Configure the ApiKey in the "General Settings" tab (visible when logged in as administrator).
The rest should be done by _Fredy_. Keep in mind, the support is experimental. There might be bugs and you might not always get pass the re-capture check, but most of the time it works pretty good :)

View File

@@ -106,6 +106,9 @@ class FredyRuntime {
}
_notify(newListings) {
if (newListings.length === 0) {
throw new NoNewListingsWarning();
}
const sendNotifications = notify.send(this._providerId, newListings, this._notificationConfig, this._jobKey);
return Promise.all(sendNotifications).then(() => newListings);
}

View File

@@ -21,6 +21,13 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
(adapter) => adapter.id === 'mailJet'
).fields;
const to = receiver
.trim()
.split(',')
.map((r) => ({
Email: r.trim(),
}));
return mailjet
.connect(apiPublicKey, apiPrivateKey)
.post('send', { version: 'v3.1' })
@@ -31,11 +38,7 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
Email: from,
Name: 'Fredy',
},
To: [
{
Email: receiver,
},
],
To: to,
Subject: `Fredy found ${newListings.length} new listings for ${serviceName}`,
HTMLPart: emailTemplate({
serviceName: `Job: (${jobKey}) | Service: ${serviceName}`,

View File

@@ -4,3 +4,5 @@ To use [MailJet](https://mailjet.com), you need to create an account. You'll nee
E.g. if you use yourGmailAccount@gmail.com, you have to add this to MailJet and verify it as well.
The given public/private api keys are needed in order to use MailJet with Fredy. Fredy will use the same template, it is using for SendGrid.
If this email should be sent to multiple receiver use a comma separator (some@email.com, someOther@email.com).

View File

@@ -14,7 +14,10 @@ exports.send = ({ serviceName, newListings, notificationConfig, jobKey }) => {
sgMail.setApiKey(apiKey);
const msg = {
templateId,
to: receiver,
to: receiver
.trim()
.split(',')
.map((r) => r.trim()),
from,
subject: `Job ${jobKey} | Service ${serviceName} found ${newListings.length} new listing(s)`,
dynamic_template_data: {

View File

@@ -6,3 +6,5 @@ SendGrid is a free email service (free as in "you cannot send more than 100(Send
To use [SendGrid](https://sendgrid.com/), you need to create an account. You'll need to decided from which email address you want Fredy to send from. E.g. if you use yourGmailAccount@gmail.com, you have to add this to sendgrid and verify it as well.
Lastly you have to create an api-key and feed it into Fredy's config, as well as creating a new dynamic template. For this new template, I recommend copying and pasting the code from the one I have provided under `/lib/notification/emailTemplate/template.hbs`.
If this email should be sent to multiple receiver use a comma separator (some@email.com, someOther@email.com).

View File

@@ -3,10 +3,7 @@ const utils = require('../utils');
let appliedBlackList = [];
function normalize(o) {
const size = o.size == null ? '--- m²' : o.size.split('Wohnfläche')[1].replace(' (ca.) ', '');
const address = o.address;
return Object.assign(o, { size, address });
return o;
}
function applyBlacklist(o) {
@@ -18,14 +15,14 @@ function applyBlacklist(o) {
const config = {
url: null,
crawlContainer: '.immoliste .js-object.listitem_wrap ',
crawlContainer: "div[class^='EstateItem-']",
crawlFields: {
id: '@data-estateid | int',
price: '.hardfacts_3 strong | removeNewline | trim',
size: '.js-object.listitem_wrap .hardfacts_3 div:nth-child(2)| removeNewline | trim',
title: '.listcontent.clear h2',
id: 'a@id',
price: "div[class^='KeyFacts-'] [data-test='price'] | removeNewline | trim",
size: "div[class^='KeyFacts-'] [data-test='area'] | removeNewline | trim",
title: "div[class^='FactsMain-'] h2",
link: 'a@href',
address: '.listcontent .details .listlocation| removeNewline | trim',
address: "div[class^='estateFacts-'] span | removeNewline | trim",
},
paginate: '#pnlPaging #nlbPlus@href',
normalize: normalize,

View File

@@ -1,6 +1,6 @@
{
"name": "fredy",
"version": "5.2.0",
"version": "5.3.0",
"description": "[F]ind [R]eal [E]states [d]amn eas[y].",
"scripts": {
"start": "node index.js",
@@ -51,60 +51,60 @@
"Firefox ESR"
],
"dependencies": {
"@rematch/core": "2.0.1",
"@rematch/loading": "2.0.1",
"@sendgrid/mail": "7.4.5",
"axios": "0.21.1",
"@rematch/core": "2.1.0",
"@rematch/loading": "2.1.0",
"@sendgrid/mail": "7.4.7",
"axios": "0.22.0",
"body-parser": "1.19.0",
"cookie-session": "1.4.0",
"handlebars": "4.7.7",
"highcharts": "9.1.2",
"highcharts": "9.2.2",
"highcharts-react-official": "3.0.0",
"lowdb": "1.0.0",
"markdown": "^0.5.0",
"nanoid": "3.1.23",
"nanoid": "3.1.28",
"node-mailjet": "3.3.4",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.4",
"react-router": "5.2.0",
"react-router-dom": "5.2.0",
"react-redux": "7.2.5",
"react-router": "5.2.1",
"react-router-dom": "5.3.0",
"react-switch": "^6.0.0",
"redux": "4.1.0",
"redux": "4.1.1",
"redux-thunk": "2.3.0",
"restana": "4.9.1",
"semantic-ui-react": "2.0.3",
"semantic-ui-react": "2.0.4",
"serve-static": "^1.14.1",
"slack": "11.0.2",
"string-similarity": "^4.0.4",
"x-ray": "2.3.4"
},
"devDependencies": {
"@babel/core": "7.14.6",
"@babel/preset-env": "7.14.7",
"@babel/core": "7.15.5",
"@babel/preset-env": "7.15.6",
"@babel/preset-react": "7.14.5",
"babel-eslint": "10.1.0",
"babel-loader": "8.2.2",
"chai": "4.3.4",
"clean-webpack-plugin": "3.0.0",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "9.0.1",
"css-loader": "5.2.6",
"eslint": "7.29.0",
"css-loader": "6.3.0",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react": "7.26.1",
"file-loader": "6.2.0",
"history": "5.0.0",
"history": "5.0.1",
"husky": "4.3.8",
"less": "4.1.1",
"less-loader": "10.0.0",
"lint-staged": "11.0.0",
"mocha": "9.0.1",
"prettier": "2.3.2",
"less-loader": "10.0.1",
"lint-staged": "11.1.2",
"mocha": "9.1.2",
"prettier": "2.4.1",
"proxyquire": "2.1.3",
"redux-logger": "3.0.6",
"style-loader": "3.0.0",
"style-loader": "3.3.0",
"url-loader": "4.1.1",
"webpack": "5.40.0",
"webpack": "5.56.0",
"webpack-cli": "3.3.12",
"webpack-dev-server": "3.11.2",
"webpack-merge": "5.8.0"

View File

@@ -30,7 +30,7 @@ describe('#immowelt testsuite()', () => {
notificationObj.payload.forEach((notify) => {
/** check the actual structure **/
expect(notify.id).to.be.a('number');
expect(notify.id).to.be.a('string');
expect(notify.price).to.be.a('string');
expect(notify.size).to.be.a('string');
expect(notify.title).to.be.a('string');

View File

@@ -9,7 +9,7 @@
"enabled": true
},
"immowelt": {
"url": "https://www.immowelt.de/liste/duesseldorf-benrath/wohnungen/kaufen?geoid=10805111000004%2C10805111000005%2C10805111000006%2C10805111000007%2C10805111000009%2C10805111000010%2C10805111000011%2C10805111000013%2C10805111000014%2C10805111000015%2C10805111000016%2C10805111000017%2C10805111000018%2C10805111000019%2C10805111000023%2C10805111000024%2C10805111000027%2C10805111000032%2C10805111000034%2C10805111000035%2C10805111000039%2C10805111000041%2C10805111000042%2C10805111000043%2C10805111000047%2C10805111000048%2C10805111000049%2C10805111000051%2C10805111000052%2C10805111000053&roomi=3&prima=420000&wflmi=90&sort=createdate%2Bdesc",
"url": "https://www.immowelt.de/liste/duesseldorf/wohnungen/kaufen?d=true&rmi=3&sd=DESC&sf=TIMESTAMP&sp=1",
"enabled": true
},
"immoscout": {

1265
yarn.lock

File diff suppressed because it is too large Load Diff