-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
352 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
a{ | ||
color:white; | ||
} | ||
|
||
#header{ | ||
font-size: 25px; | ||
} | ||
|
||
#loading{ | ||
display:none; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
|
||
const searchCar = document.querySelector("#search-car"); | ||
|
||
// const button = document.querySelector("#button"); | ||
|
||
document.querySelector('#getads').addEventListener('click',loadads); | ||
|
||
|
||
function loadads(){ | ||
|
||
console.log("fonksiyon çalışıyor") | ||
var loadImage = document.querySelector('#loading'); | ||
loadImage.style.display = 'block'; | ||
|
||
var url ='/v1/spawn/sahibinden' | ||
const xhr = new XMLHttpRequest(); | ||
|
||
xhr.open('GET', url, true); | ||
|
||
setTimeout(() => | ||
{ | ||
xhr.onload = function() | ||
{ | ||
loadImage.style.display="none"; | ||
console.log(this.responseText); | ||
|
||
if(this.status === 200) | ||
{ | ||
|
||
let ads = JSON.parse(this.responseText) | ||
console.log(ads) | ||
|
||
let html=""; | ||
|
||
ads.forEach(ad => { | ||
console.log(ad.price) | ||
html+= `<tr> | ||
<td id="price">${ad.price}</td> | ||
<td id="year">${ad.year}</td> | ||
<td id="km">${ad.km}</td> | ||
<td id="color">${ad.color}</td> | ||
</tr>`; | ||
}); | ||
|
||
document.querySelector('#ads').innerHTML = html; | ||
|
||
} | ||
} | ||
xhr.send(); | ||
|
||
}, 1500); | ||
} | ||
|
||
searchCar.addEventListener("keypress", (event)=> | ||
{ | ||
let text = event.target.value; | ||
|
||
if(text !== "") | ||
{ | ||
console.log(text); | ||
} | ||
|
||
}) | ||
|
||
|
||
// button.addEventListener('click', (updateButton)=> | ||
// { | ||
// if (button.value === 'Start machine') | ||
// { | ||
// button.value = 'Stop machine'; | ||
// alert("The machine has started!"); | ||
// } | ||
// else | ||
// { | ||
// button.value = 'Start machine'; | ||
// alert('The machine is stopped.'); | ||
// } | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
[ | ||
{"price": "194.900TL", "year": "2018", "km": "80.450", "color": "Beyaz"}, | ||
{"price": "159.500TL", "year": "2015", "km": "147.000", "color": "Beyaz"}, | ||
{"price": "77.000TL", "year": "2004", "km": "270.000", "color": "G\u00fcm\u00fc\u015f"}, | ||
{"price": "81.750TL", "year": "2008", "km": "233.000", "color": "Siyah"}, | ||
{"price": "123.850TL", "year": "2008", "km": "170.000", "color": "Gri"}, | ||
{"price": "152.950TL", "year": "2012", "km": "125.000", "color": "Beyaz"}, | ||
{"price": "86.500TL", "year": "2009", "km": "142.900", "color": "Mavi"}, | ||
{"price": "168.500TL", "year": "2015", "km": "99.000", "color": "Beyaz"}, | ||
{"price": "127.950TL", "year": "2012", "km": "178.000", "color": "Lacivert"}, | ||
{"price": "81.950TL", "year": "2007", "km": "260.919", "color": "Gri"}, | ||
{"price": "131.000TL", "year": "2012", "km": "184.000", "color": "Beyaz"}, | ||
{"price": "129.750TL", "year": "2013", "km": "124.000", "color": "Beyaz"}, | ||
{"price": "183.750TL", "year": "2017", "km": "63.500", "color": "Beyaz"}, | ||
{"price": "199.950TL", "year": "2018", "km": "97.000", "color": "Beyaz"}, | ||
{"price": "156.750TL", "year": "2016", "km": "70.910", "color": "Beyaz"}, | ||
{"price": "102.000TL", "year": "2004", "km": "193.500", "color": "Lacivert"}, | ||
{"price": "262.950TL", "year": "2021", "km": "0", "color": "Beyaz"}, | ||
{"price": "152.950TL", "year": "2012", "km": "151.000", "color": "F\u00fcme"} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,59 @@ | ||
|
||
const express = require('express') | ||
const app = express() | ||
const port = 3000 | ||
const child = require("child_process"); | ||
const path = require("path") | ||
const util = require("util") | ||
const axios = require("axios") | ||
|
||
const exec = util.promisify(child.exec); | ||
|
||
app.get('/v1/spawn/sahibinden' ,async (req, res) => | ||
{ | ||
const { stdout, stderr } = await exec(`python ${path.join(__dirname,'./sahibinden.py')}`) | ||
|
||
if(stderr) { | ||
return res.send({error:stderr.toString()}) | ||
} | ||
|
||
res.send({stdout:stdout}) | ||
}) | ||
|
||
app.get('/', async (req, res) => | ||
{ | ||
res.status(200).send({message:'tamam'}) | ||
}) | ||
|
||
app.get('/auth', async (req, res) => | ||
{ | ||
const sessionId = req.query.sessionId | ||
|
||
if(!sessionId) { | ||
return res.status(422).send({message:'sessionId gerekli.'}) | ||
} | ||
|
||
const response = await axios.get('http://api.app-platform.rgmbeta.com/api/v1/auth/getSessionInfo',{ | ||
params:{ | ||
sessionId:sessionId, | ||
appName:'ebrutezel/sahibinden-scrapper', | ||
secretKey:'ca139f7a53fc441189639251ac3688d9' | ||
} | ||
}) | ||
|
||
if(!response.data.data) { | ||
return res.status(403).send({message:'yetkilendirme başarısız'}) | ||
} | ||
|
||
res.redirect('/') | ||
}) | ||
|
||
app.listen(port, () => | ||
{ | ||
console.log(`http://localhost:${port}`) | ||
|
||
const express = require("express"); | ||
const app = express() | ||
const port = 3000 | ||
const child = require("child_process"); | ||
const path = require("path") | ||
const util = require("util") | ||
const axios = require("axios") | ||
|
||
const exec = util.promisify(child.exec); | ||
app.use("public",express.static('../public')) | ||
|
||
app.get('/v1/spawn/sahibinden' ,async (req, res) => | ||
{ | ||
const { stdout, stderr } = await exec(`python ${path.join(__dirname,'/script/sahibinden.py')}`) | ||
|
||
if(stderr) { | ||
return res.send({error:stderr.toString()}) | ||
} | ||
|
||
res.send({stdout:stdout}) | ||
}) | ||
|
||
app.get('/', async (req, res) => | ||
{ | ||
res.sendFile(path.join(__dirname+'/template/form.html')); | ||
}) | ||
|
||
app.get('/auth', async (req, res) => | ||
{ | ||
const sessionId = req.query.sessionId | ||
|
||
if(!sessionId) | ||
{ | ||
return res.status(422).send({message:'sessionId gerekli.'}) | ||
} | ||
|
||
const response = await axios.get('http://api.app-platform.rgmbeta.com/api/v1/auth/getSessionInfo', | ||
{ | ||
params: | ||
{ | ||
sessionId:sessionId, | ||
appName:'ebrutezel/sahibinden-scrapper', | ||
secretKey:'ca139f7a53fc441189639251ac3688d9' | ||
} | ||
}) | ||
|
||
if(!response.data.data) | ||
{ | ||
return res.status(403).send({message:'yetkilendirme başarısız'}) | ||
} | ||
|
||
res.redirect('/') | ||
}) | ||
|
||
app.listen(port, () => | ||
{ | ||
console.log(`http://localhost:${port}`) | ||
}) |
Oops, something went wrong.