removed api part since not needed anymore
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
import fetch from 'node-fetch';
|
||||
import { BASE_URL, BASE_HEADERS, BASE_PARAMS } from '../util/Constants';
|
||||
|
||||
const cookie = {
|
||||
JSESSIONID: "ffu-WeUdcd3ICqoCimutvnpdERv3XONZ-VMxwg4-.eteenindusw-n1",
|
||||
mntClientId: "15QY8LHHIST1C",
|
||||
ROUTEID: ".et1",
|
||||
plumbr_user_tracker: "a71e97ae-1d54-5fce-a758-cbf37e01c093",
|
||||
plumbr_session_tracker_bkae1x: "004aec88-b58e-036b-2c05-ee309bfaa88b|1590327356024"
|
||||
};
|
||||
|
||||
const formatCookie = 'JSESSIONID=OWbYYl4zGt6GOBW8nHFf9jX836540u0Bi-y5T6hf.eteenindusw-n1; mntClientId=15QY8LHHIST1C; ROUTEID=.et1; eteenindus_lang=en';
|
||||
|
||||
class Api {
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* @param {string} plate @TODO implement usage
|
||||
*/
|
||||
async fetch(plate = "") {
|
||||
try {
|
||||
console.log(`Fetching data for ${plate}`);
|
||||
return (await fetch(BASE_URL, {
|
||||
"headers": {
|
||||
...BASE_HEADERS,
|
||||
"Cookie": formatCookie
|
||||
},
|
||||
...BASE_PARAMS,
|
||||
})).text();
|
||||
} catch (e) {
|
||||
throw Error(`Failed to fetch data, reason: ${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Api;
|
||||
@@ -1,17 +1,11 @@
|
||||
import jsdom from "jsdom";
|
||||
import { JSDOM } from "jsdom";
|
||||
import Car from "../model/Car";
|
||||
import Selectors from '../util/Selectors';
|
||||
|
||||
const {
|
||||
JSDOM
|
||||
} = jsdom;
|
||||
|
||||
class Scraper {
|
||||
document;
|
||||
car;
|
||||
|
||||
constructor() {}
|
||||
|
||||
setContent(text) {
|
||||
const parsedContent = new JSDOM(text).window.document;
|
||||
if (parsedContent.querySelector(Selectors.properties.main.container) === null) {
|
||||
|
||||
@@ -1,18 +1,14 @@
|
||||
import { BASE_URL, BASE_HEADERS, BASE_PARAMS } from './util/Constants';
|
||||
import Car from './model/Car';
|
||||
import Api from './api/Api';
|
||||
import Cache from './api/Cache';
|
||||
import Cache from './util/Cache';
|
||||
import Scraper from './components/Scraper';
|
||||
import CookieMonster from './cookies/CookieMonster';
|
||||
|
||||
class Hack {
|
||||
api;
|
||||
scraper;
|
||||
cache;
|
||||
cookieMonster;
|
||||
|
||||
constructor() {
|
||||
this.api = new Api();
|
||||
this.scraper = new Scraper();
|
||||
this.cache = new Cache();
|
||||
this.cookieMonster = new CookieMonster(this.cache);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Cacheman from 'cacheman';
|
||||
import { CACHE } from '../util/Constants';
|
||||
import { CACHE } from './Constants';
|
||||
|
||||
class Cache {
|
||||
manager;
|
||||
@@ -1,34 +1,18 @@
|
||||
export const BASE_URL = 'https://eteenindus.mnt.ee/public/soidukDetailvaadeAvalik.jsf';
|
||||
export const SEARCH_URL = 'https://eteenindus.mnt.ee/public/soidukTaustakontroll.jsf';
|
||||
|
||||
export const BASE_HEADERS = {
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
|
||||
'Accept-Encoding': 'gzip, deflate, br',
|
||||
'Accept-Language': 'en-US,en;q=0.5',
|
||||
'Connection': 'keep-alive',
|
||||
'Host': 'eteenindus.mnt.ee',
|
||||
'Referrer': BASE_URL,
|
||||
'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:76.0) Gecko/20100101 Firefox/76.0',
|
||||
'Upgrade-Insecure-Requests': '1',
|
||||
};
|
||||
|
||||
export const BASE_PARAMS = {
|
||||
'method': 'GET',
|
||||
'mode': 'cors',
|
||||
'credentials': 'include',
|
||||
};
|
||||
|
||||
export const NAVIGATION_TIMEOUT = 2500;
|
||||
|
||||
const TMP_DIR = 'tmp';
|
||||
export const CACHE = {
|
||||
ttl: 600,
|
||||
engine: 'file',
|
||||
directory: 'tmp/cache',
|
||||
directory: `${TMP_DIR}/cache`,
|
||||
PREFIX: {
|
||||
plate: 'car-',
|
||||
},
|
||||
};
|
||||
|
||||
export const TEMP_DIR = {
|
||||
screenshots: 'tmp/screenshots',
|
||||
}
|
||||
screenshots: `${TMP_DIR}/screenshots`,
|
||||
};
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export const formatCookie = Object.entries(cookie)
|
||||
.map(([key, value]) => `${key}=${value}`)
|
||||
.join('; ');
|
||||
Reference in New Issue
Block a user