Skip to content

Commit 1044aa9

Browse files
committed
Fix getdriverStandings method
1 parent 9b8d00c commit 1044aa9

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/scraper/driver-lineup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const getDriverLineup = async (): Promise<isDriver[]> => {
3939
$("a.group").each(function () {
4040
const firstName: string = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > p:nth-child(1)").text().trim();
4141
const secondName: string = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > p:nth-child(2)").text().trim();
42-
const team: string = $(this).find("div:nth-child(1) > div:nth-child(1) > p:nth-child(3)").text();
42+
const team: string = $(this).find("div:nth-child(1) > div:nth-child(1) > p:nth-child(3)").text().trim();
4343
const nationalityImage: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > img:nth-child(2)").attr("src");
4444
const driverImage: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(4) > img:nth-child(2)").attr("src");
4545

src/scraper/driver-standings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export const getDriverStandings = async (year: number = new Date().getFullYear()
1313
const $ = cheerio.load(response.data);
1414

1515
$(".f1-table > tbody:nth-child(2) > tr").each(function () {
16-
const position: number = parseInt($(this).find("td:nth-child(1) > p:nth-child(1)").text());
17-
const driver_1: string = $(this).find("td:nth-child(2) > p:nth-child(1) > a:nth-child(1) > span:nth-child(1)").text();
18-
const driver_2: string = $(this).find("td:nth-child(2) > p:nth-child(1) > a:nth-child(1) > span:nth-child(2)").text();
19-
const driver: string = driver_1.concat(" ", driver_2);
16+
const position: number = parseInt($(this).find("td:nth-child(1) > p:nth-child(1)").text().trim());
17+
const driver_1: string = $(this).find("td:nth-child(2) > p:nth-child(1) > a:nth-child(1) > span:nth-child(1)").text().trim();
18+
const driver_2: string = $(this).find("td:nth-child(2) > p:nth-child(1) > a:nth-child(1) > span:nth-child(2)").text().trim();
19+
const driver: string = driver_1.concat(" ", driver_2.slice(0, driver_2.length - 3));
2020
const nationality: string = $(this).find(" td:nth-child(3) > p:nth-child(1)").text();
2121
const team: string = $(this).find("td:nth-child(4) > p:nth-child(1) > a:nth-child(1)").text();
2222
const points: number = parseInt($(this).find(" td:nth-child(5) > p:nth-child(1) ").text());

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export { getFastestLaps } from "./scraper/fastest-laps";
22
export { getDriverLineup } from "./scraper/driver-lineup";
33
export { getTeamLineup } from "./scraper/team-lineup";
4-
// export { getDriverStandings } from "./scraper/driver-standings";
4+
export { getDriverStandings } from "./scraper/driver-standings";
55
// export { getConstructorStandings } from "./scraper/constructors-standings";
66
// export { getWorldChampions } from "./scraper/world-champions";
77
// export { getRaceResults } from "./scraper/race-results";

0 commit comments

Comments
 (0)