Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { readFile, writeFile } from 'fs/promises';
- async function convert() {
- const rawdata = await readFile('raw.tsv', { encoding: 'utf8' })
- const rows = rawdata.replace(/\r/g,'').split('\n')
- const objdata = rows.map(row => {
- const col = row.split('\t')
- return ({
- id: col[0],
- legal: col[1],
- company: col[2],
- address: col[3],
- municipality: col[4],
- latitude: col[5],
- longitude: col[6]
- })
- })
- await writeFile('objdata.json', JSON.stringify(objdata, null, 4))
- }
- convert();
- import fetch from 'node-fetch';
- import { load } from 'cheerio';
- import { readFile, writeFile } from 'fs/promises';
- let data = [];
- async function example(i) {
- try {
- const $ = load(await readFile('neo/'+i+'.html', { encoding: 'utf8' }));
- $('tbody > tr').each( function (i,e) {
- let appId = $(this).find('a').attr('onclick')?.split(';')[0]?.split('=')[1];
- data.push([...$(this).text().split('\n').filter(i => i.trim()).map(i => i.trim()),appId]);
- });
- //console.log(data);
- } catch (err) {
- // console.log(err);
- }
- }
- async function platosmikos(appid, all) {
- const $ = load(await (await fetch("https://keraies.eett.gr/getDetails.php", {
- "headers": {
- "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
- "accept-language": "en-GB,en;q=0.9,en-US;q=0.8,el;q=0.7",
- "cache-control": "max-age=0",
- "content-type": "application/x-www-form-urlencoded",
- "sec-ch-ua": "\"Not/A)Brand\";v=\"99\", \"Google Chrome\";v=\"115\", \"Chromium\";v=\"115\"",
- "sec-ch-ua-mobile": "?1",
- "sec-ch-ua-platform": "\"Android\"",
- "sec-fetch-dest": "document",
- "sec-fetch-mode": "navigate",
- "sec-fetch-site": "same-origin",
- "sec-fetch-user": "?1",
- "upgrade-insecure-requests": "1",
- "Referer": "https://keraies.eett.gr/getData.php",
- "Referrer-Policy": "strict-origin-when-cross-origin"
- },
- "body": "appId="+appid,
- "method": "POST"
- }))?.text());
- let platos = $('body > div:nth-child(5) > div:nth-child(1) > div:nth-child(4) > div:nth-child(2) > p.list-group-item-heading2').text();
- let mikos = $('body > div:nth-child(5) > div:nth-child(1) > div:nth-child(5) > div:nth-child(2) > p.list-group-item-heading2').text();
- console.log (appid + '[|]' + all.join('[|]') + '[|]' + platos + '[|]' + mikos);
- return [platos,mikos];
- }
- async function printem() {
- for (let i= 1 ;i<= 100 ;i++) {
- await example(i);
- }
- data = data.map((e,i) => [
- (++i).toString(),
- ...e,
- platosmikos(e.slice(-1)[0], e)
- ]);
- /*await writeFile(
- './file.json',
- JSON.stringify(data),
- function (err) {
- if (err) {
- // console.error('Crap happens');
- }
- }
- );*/
- }
- printem();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement