Skip to content

Commit

Permalink
add standings football
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Mar 20, 2024
1 parent 069b9ef commit 3f327d6
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const scrape = require("scrape-websitee")
filmApikDl, // (url)
otakuDesuSearch, // (query)
},
football: {
standings
},
random: {
anime: {
neko,
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = {
tools: require("./src/tools.js"),
downloader: require("./src/downloader.js"),
search: require("./src/search.js"),
football: require("./src/football.js"),
random: require("./src/random.js"),
ai: require("./src/ai.js")
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scrape-websitee",
"version": "1.0.71",
"version": "1.0.72",
"description": "Website Scraping",
"main": "index.js",
"scripts": {
Expand Down
153 changes: 153 additions & 0 deletions src/football.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
const axios = require("axios")
const cheerio = require("cheerio")

async function standings(league) {
let result = []
let liga = league.toLowerCase()
const perancis = liga === "france" || liga === "prancis" || liga === "perancis" || liga === "ligue 1"
const jerman = liga === "german" || liga === "germany" || liga === "bundes liga" || liga === "bundesliga" || liga === "jerman"
const ind = liga === "indonesia" || liga === "indo" || liga === "ind"
const eng = liga === "inggris" || liga === "premier league" || liga === "english" || liga === "premier" || liga === "england"
const italy = liga === "italia" || liga === "italy" || liga === "serie a"
const spanyol = liga === "spain" || liga === "spanyol" || liga === "la liga" || liga === "laliga"
const ucl = liga === "ucl" || liga === "champion" || liga === "champions"
try {
if (ucl) {
const { data } = await axios.get("https://www.bola.net/klasemen/champions.html")
let $ = cheerio.load(data)
$("div.box-group > div").each(function () {
const group = $(this).find("h3").text()
result[group] = []
$(this)
.find("div > table > tbody > tr")
.each(function () {
result[group].push({
rank: $(this).find("th > div > span:nth-child(1)").text(),
name: $(this).find("th > div > span:nth-child(2) a > span:nth-child(2)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
})
return result
}
if (eng) {
const { data } = await axios.get("https://www.bola.net/klasemen/inggris.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
if (jerman) {
const { data } = await axios.get("https://www.bola.net/klasemen/jerman.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
if (perancis) {
const { data } = await axios.get("https://www.bola.net/klasemen/prancis.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
if (ind) {
const { data } = await axios.get("https://www.bola.net/klasemen/indonesia.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
if (spanyol) {
const { data } = await axios.get("https://www.bola.net/klasemen/spanyol.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
if (italy) {
const { data } = await axios.get("https://www.bola.net/klasemen/italia.html")
let $ = cheerio.load(data)
$("table.main-table > tbody > tr").each(function () {
result.push({
name: $(this).find("th > div > span:nth-child(2) > a > span:nth-child(2)").text(),
rank: $(this).find("th > div > span:nth-child(1)").text(),
match: $(this).find("td:nth-child(2)").text(),
point: $(this).find("td:nth-child(3)").text(),
win: $(this).find("td:nth-child(4)").text(),
draw: $(this).find("td:nth-child(5)").text(),
lose: $(this).find("td:nth-child(6)").text(),
goals: $(this).find("td:nth-child(7)").text(),
gd: $(this).find("td:nth-child(8)").text()
})
})
return result
}
} catch (err) {
console.log(err)
return String(err)
}
}

module.exports = { standings }

0 comments on commit 3f327d6

Please sign in to comment.