Skip to content

Instantly share code, notes, and snippets.

@emindeniz99
Created June 22, 2020 20:51
Show Gist options
  • Save emindeniz99/670c2b0e991d6b569efbc48dbf7be0f7 to your computer and use it in GitHub Desktop.
Save emindeniz99/670c2b0e991d6b569efbc48dbf7be0f7 to your computer and use it in GitHub Desktop.
Boun Quota Scrap
const axios = require("axios")
const cheerio = require("cheerio")
const sendNotification = async (link) => {
let data = ""
console.log("testaaa")
await axios.get(link).then((res) => {
console.log()
data = res.data
})
const $ = cheerio.load(data)
// $("h2.title").text("Hello there!")
// $("h2").addClass("welcome")
// let str = $("tr[class=schtd]").text()
// console.log($(" center font").text())
// console.log($("tr[class=schtd] td").filter("td")[2].childNodes[0].children[0].data)
// console.log($("tr[class=schtd] td").filter("td")[3].childNodes[0].children[0].data)
let maxkota = Number(
$("tr[class=schtd] td").filter("td")[2].childNodes[0].children[0].data
)
let curr = Number(
$("tr[class=schtd] td").filter("td")[3].childNodes[0].children[0].data
)
let className = $(" center font").text()
let mes
if (maxkota == curr) {
mes = className + " dolu " + curr + "/" + maxkota
console.log(className + " dolu " + curr + "/" + maxkota)
} else {
mes = className + " boş yer var " + curr + "/" + maxkota
console.log(className + " boş yer var " + curr + "/" + maxkota)
/* await axios
.post(
"https://api.telegram.org/"+
"bot>BOTSECRETKEY<"
+"/sendMessage",
{ chat_id: <CHATID>, text: mes }
)
.then(function (response) {
console.log(response.data)
}) */
}
}
exports.handler = async (event) => {
// TODO implement
let links = [
"https://registration.boun.edu.tr/scripts/quotasearch.asp?abbr=PHYS&code=201&section=01&donem=2019/2020-3",
"https://registration.boun.edu.tr/scripts/quotasearch.asp?abbr=PHYS&code=201&section=02&donem=2019/2020-3",
]
let tasks = []
links.forEach(async (link) => {
tasks.push(sendNotification(link))
})
await Promise.all(tasks)
// console.log(str.split(" "))
// str.split(" ").forEach((dd)=>console.log(dd))
// const response = {
// statusCode: 200,
// body: JSON.stringify("Hello from !"),
// }
// return response
}
// exports.handler()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment