fix naming
This commit is contained in:
@@ -6,6 +6,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
extends: ['airbnb'],
|
extends: ['airbnb'],
|
||||||
rules: {
|
rules: {
|
||||||
'lines-between-class-members': 0
|
'lines-between-class-members': 0,
|
||||||
}
|
'no-console': 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class Scraper {
|
|||||||
setContent(text) {
|
setContent(text) {
|
||||||
const parsedContent = new JSDOM(text).window.document;
|
const parsedContent = new JSDOM(text).window.document;
|
||||||
if (parsedContent.querySelector(Selectors.properties.main.container) === null) {
|
if (parsedContent.querySelector(Selectors.properties.main.container) === null) {
|
||||||
throw Error('No data was received. Cookie is probably expired.');
|
throw Error('No data was received.. Something went wrong.');
|
||||||
}
|
}
|
||||||
this.document = parsedContent;
|
this.document = parsedContent;
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/index.js
11
src/index.js
@@ -1,19 +1,16 @@
|
|||||||
import Car from './model/Car';
|
|
||||||
import Cache from './util/Cache';
|
import Cache from './util/Cache';
|
||||||
import Scraper from './components/Scraper';
|
import Scraper from './components/Scraper';
|
||||||
import CookieMonster from './cookies/CookieMonster';
|
import Fetcher from './api/Fetcher';
|
||||||
|
|
||||||
class Hack {
|
class Hack {
|
||||||
scraper;
|
scraper;
|
||||||
|
|
||||||
cache;
|
cache;
|
||||||
|
fetcher;
|
||||||
cookieMonster;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.scraper = new Scraper();
|
this.scraper = new Scraper();
|
||||||
this.cache = new Cache();
|
this.cache = new Cache();
|
||||||
this.cookieMonster = new CookieMonster(this.cache);
|
this.fetcher = new Fetcher(this.cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getData(plate) {
|
async getData(plate) {
|
||||||
@@ -22,7 +19,7 @@ class Hack {
|
|||||||
console.log(`Using cached data for ${plate}`);
|
console.log(`Using cached data for ${plate}`);
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
const data = await this.cookieMonster.init(plate);
|
const data = await this.fetcher.init(plate);
|
||||||
this.cache.save(plate, data);
|
this.cache.save(plate, data);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user