const { Builder, By, until } = require('selenium-webdriver'); const express = require('express'); const app = express(); const port = 5656; const basms = Date.now(); let driver; async function initializeDriver() { driver = await new Builder().forBrowser('chrome').build(); await driver.get('https://cas.hatay.bel.tr:8071/cas/login'); const username = await driver.findElement(By.id('username')); const password = await driver.findElement(By.id('password')); const giris = await driver.findElement(By.name('submit')); await username.sendKeys('cozsoy'); await password.sendKeys('Cc123456'); await giris.click(); await driver.get('https://ybs.hatay.bel.tr/FlexCityUi/'); await driver.sleep(8000); } async function performQuery(tc, dogumtarihi) { const waitAndClick = async (xpath) => { const element = await driver.wait(until.elementLocated(By.xpath(xpath)), 4500); await element.click(); }; const clearAndSendKeys = async (xpath, value) => { const element = await driver.wait(until.elementLocated(By.xpath(xpath)), 4500); await element.clear(); await element.sendKeys(value); }; await waitAndClick('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[1]/div/div[7]'); await driver.sleep(2000); await waitAndClick('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[1]/div/div/div/div[1]/div/div[2]/div/div[1]/div[1]/div[2]/div[5]/div[1]/div/span'); await driver.sleep(2000); await clearAndSendKeys('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[1]/div/div[2]/div/div[2]/div/div/div/div/div/div/div[1]/div/table/tbody/tr/td[3]/div/div/div/input', tc); await clearAndSendKeys('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[1]/div/div[2]/div/div[2]/div/div/div/div/div/div/div[2]/div/table/tbody/tr/td[3]/div/input', dogumtarihi); await waitAndClick('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[2]/div/div[1]/div'); await driver.sleep(4000); const getValueByXPath = async (xpath) => { const element = await driver.wait(until.elementLocated(By.xpath(xpath)), 5000); return element.getAttribute('value'); }; const ad = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[5]/td[3]/input'); const soyad = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[6]/td[3]/input'); const dyer = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[9]/td[3]/input'); const aad = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[8]/td[3]/input'); const bad = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[7]/td[3]/input'); const cinsiyet = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[2]/td[3]/input'); const dini = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[3]/td[3]/input'); const mahalle = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[7]/td[3]/input'); const ciltno = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[8]/td[3]/input'); const asno = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[3]/td[3]/input'); const medeni = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[1]/td[3]/input'); const evlenmet = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[10]/td[3]/input'); const bosanmat = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[11]/td[3]/input'); const il = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[5]/td[3]/input'); const ilce = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[6]/td[3]/input'); const ölümtar = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[2]/div/table/tbody/tr[4]/td[3]/input'); const serino = await getValueByXPath('/html/body/div[1]/div/div[2]/div/div/div[3]/div/div[2]/div/div/div/div[2]/div/div[1]/div/div/div[2]/div/div/div/div/div/div[4]/div/div/div/div/div[2]/div/div/div/div[1]/div/div/div[2]/div/div/div/div/div/div/div/div[1]/div/table/tbody/tr[4]/td[3]/input'); const din = dini || 'İslam'; const ölümt = ölümtar || 'Yaşıyor'; const mssonuc = `${basms - Date.now()}ms`; const jsoncevir = { INFO: { Ms: mssonuc, Own: 'Aventus', }, DATA: { KimlikNumarası: tc, Adi: ad, SoyAdi: soyad, DogumTarihi: dogumtarihi, DogumYeri: dyer, Cinsiyet: cinsiyet, AnneAdi: aad, BabaAdi: bad, Din: din, ÖlümTarihi: ölümt, EvlenmeTarihi: evlenmet, BosanmaTarihi: bosanmat, MedeniHal: medeni, NufusIL: il, NufusILCE: ilce, Mahalle: mahalle, CiltNo: ciltno, serinofirst: asno, Serino: serino, }, }; return jsoncevir; } async function handleQuery(req, res) { const { tc, dogumtarihi } = req.query; try { if (!driver) { await initializeDriver(); } const jsoncevir = await performQuery(tc, dogumtarihi); return res.json(jsoncevir); } catch (error) { console.error('An error occurred:', error); return res.status(500).json({ error: 'Internal Server Error' }); } } app.get('/serino', handleQuery); app.listen(port, () => { console.log('Başlatıldı'); });