1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { load } from "https://esm.sh/cheerio";
import { fetchText } from "https://esm.town/v/stevekrouse/fetchText?v=6";
const defaultAsEmptyString = (value) => value ?? "";
const forbetEventScrapper = (html) => {
const $ = load(html);
// Main Info
const homeTeam = $('.predictioncontain *[itemprop="homeTeam"] span').text();
const homeTeamLink = $('.predictioncontain *[itemprop="homeTeam"] a').attr(
"href"
);
const awayTeam = $('.predictioncontain *[itemprop="awayTeam"] span').text();
const awayTeamLink = $('.predictioncontain *[itemprop="awayTeam"] a').attr(
"href"
);
const weather = $(".predictioncontain .weather_main_pr > span").text();
const date = $('.predictioncontain *[itemprop="startDate"]').text();
const result = $(".predictioncontain .match_res b").text();
const tournament = $(".teamtablesp_container .leagpredlnk").text();
const prediction = $(".predictioncontain .inPred").text();
const round = $("#1x2_table .heading").text();
// Probabilities
const probability1 = $("#1x2_table .rcnt > .fprc > span:nth-child(1)").text();
const probabilityX = $("#1x2_table .rcnt > .fprc > span:nth-child(2)").text();
const probability2 = $("#1x2_table .rcnt > .fprc > span:nth-child(3)").text();
// Odds 1X2
const odds1X2Home = $(
"#1x2_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(1)"
).text();
const odds1X2Draw = $(
"#1x2_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(2)"
).text();
const odds1X2Away = $(
"#1x2_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(3)"
).text();
// Odds Over/Under
const oddsOver = $(
"#uo_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(2)"
).text();
const oddsUnder = $(
"#uo_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(1)"
).text();
// Odds BTTS
const oddsBTTSYes = $(
"#bts_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(1)"
).text();
const oddsBTTSNo = $(
"#bts_table > div.rcnt.tr_0 > div.bigOnly.prmod > div > span:nth-child(2)"
).text();
const avgGoals = $("#1x2_table .rcnt .avg_sc").text();
const matchIntro = $(".stat-content .match_intro_text").text();
// Last 6 matches
const homeLast6MatchesWins = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(1) > div > div > div.st_row_perc > div.st_perc_stat.winres > div > span:nth-child(2)"
).text();
const homeLast6MatchesDraws = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(1) > div > div > div.st_row_perc > div.st_perc_stat.drawres > div > span:nth-child(2)"
).text();
const homeLast6MatchesLose = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(1) > div > div > div.st_row_perc > div.st_perc_stat.loseres > div > span:nth-child(2)"
).text();
const awayLast6MatchesWins = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(2) > div > div > div.st_row_perc > div.st_perc_stat.winres > div > span:nth-child(2)"
).text();
const awayLast6MatchesDraws = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(2) > div > div > div.st_row_perc > div.st_perc_stat.drawres > div > span:nth-child(2)"
).text();
const awayLast6MatchesLose = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(4) > td:nth-child(2) > div > div > div.st_row_perc > div.st_perc_stat.loseres > div > span:nth-child(2)"
).text();
const homePlayedGames = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(8) > td > section > div:nth-child(1) > div:nth-child(2) > div > div:nth-child(1) > span"
).text();
const awayPlayedGames = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(8) > td > section > div:nth-child(1) > div:nth-child(2) > div > div:nth-child(2) > span"
).text();
// Goals
const homeScoredGoals = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(8) > td > section > div:nth-child(1) > div:nth-child(3) > div.os_goals_section1_main.os_flex_sb.__sm_section > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span.__total_num.t
).text();
const homeScoredGoalsAvg = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(8) > td > section > div:nth-child(1) > div:nth-child(3) > div.os_goals_section1_main.os_flex_sb.__sm_section > div:nth-child(1) > div:nth-child(1) > div.os_goals_section1_child.__right_c
).text();
const homeConcededGoals = $(
".contentmiddle > div > table.stat-content > tbody > tr:nth-child(8) > td > section > div:nth-child(1) > div:nth-child(3) > div.os_goals_section1_main.os_flex_sb.__sm_section > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > span.__total_num.t
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
June 19, 2024