Skip to content

Commit 19ec8e2

Browse files
committed
Driver lineup fix
1 parent 383592a commit 19ec8e2

File tree

4 files changed

+18
-21
lines changed

4 files changed

+18
-21
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
dist
33
junk * log.env
4+
5+
src/index.ts

src/index.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/scraper/driver-lineup.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ export const getDriverLineup = async (): Promise<isDriver[]> => {
1313
const $ = cheerio.load(response.data);
1414

1515
// drivers with ranking
16-
$("a.focus-visible\\:outline-0").each(function () {
17-
const firstName: string = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(1) > p:nth-child(1)").text().trim();
18-
const secondName: string = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(1) > p:nth-child(2)").text().trim();
19-
const team: string = $(this).find("div:nth-child(1) > div:nth-child(1) > p:nth-child(5)").text();
20-
const rank: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > p:nth-child(1)").text().trim();
21-
const nationalityImage: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(3) > img:nth-child(2)").attr("src");
22-
const driverImage: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(1) > div:nth-child(6) > img:nth-child(2)").attr("src");
16+
$("a[data-f1rd-a7s-click=driver_card_click]").each(function (index: number) {
17+
const firstName: string = $(this).find("div:nth-child(1) > div:nth-child(4) > p:nth-child(1)").text().trim();
18+
const secondName: string = $(this).find("div:nth-child(1) > div:nth-child(4) > p:nth-child(2)").text().trim();
19+
const team: string = $(this).find("div:nth-child(1) > div:nth-child(4) > div:nth-child(3) > p:nth-child(1)").text();
20+
const rank: string | undefined = String(++index);
21+
22+
//Updated to retrieve SVG due to switch to SVG flags
23+
const nationalityImage: string = $(this).find("div:nth-child(1) > div:nth-child(6)").html() || "";
24+
const driverImage: string | undefined = $(this).find("div:nth-child(1) > div:nth-child(7) > div:nth-child(1) > img").attr("src");
2325

2426
if (firstName.length !== 0 && secondName.length !== 0 && team.length !== 0 && rank?.length !== 0 && nationalityImage?.length !== 0 && driverImage?.length !== 0) {
2527
const driver: isDriver = {

src/server.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
export { getFastestLaps } from "./scraper/fastest-laps";
1+
// export { getFastestLaps } from "./scraper/fastest-laps";
22
export { getDriverLineup } from "./scraper/driver-lineup";
3-
export { getTeamLineup } from "./scraper/team-lineup";
4-
export { getDriverStandings } from "./scraper/driver-standings";
5-
export { getConstructorStandings } from "./scraper/constructors-standings";
6-
export { getWorldChampions } from "./scraper/world-champions";
7-
export { getRaceResults } from "./scraper/race-results";
8-
export { getRaceSchedule } from "./scraper/race-schedule";
3+
// export { getTeamLineup } from "./scraper/team-lineup";
4+
// export { getDriverStandings } from "./scraper/driver-standings";
5+
// export { getConstructorStandings } from "./scraper/constructors-standings";
6+
// export { getWorldChampions } from "./scraper/world-champions";
7+
// export { getRaceResults } from "./scraper/race-results";
8+
// export { getRaceSchedule } from "./scraper/race-schedule";

0 commit comments

Comments
 (0)