Skip to content

Commit 6936268

Browse files
committed
Fixed fastest laps
1 parent 19ec8e2 commit 6936268

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/scraper/fastest-laps.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,16 @@ export const getFastestLaps = async (year: number = new Date().getFullYear()): P
1111

1212
const response = await axios(`${dynamicLinks.rootLink}/${year}/${dynamicLinks.fastestLap}`);
1313
const $ = cheerio.load(response.data);
14+
console.log(`${dynamicLinks.rootLink}/${year}/${dynamicLinks.fastestLap}`);
1415

1516
$(".f1-table > tbody:nth-child(2) > tr").each(function () {
16-
const grandPrix: string = $(this).find("td:nth-child(1) > p:nth-child(1)").text().trim();
17-
const driverFirstName: string = $(this).find("td:nth-child(2) > p:nth-child(1) > span:nth-child(1)").text().trim();
18-
const driverLastName: string = $(this).find("td:nth-child(2) > p:nth-child(1) > span:nth-child(2)").text().trim();
17+
const grandPrixAll: Text = $(this).find("td:nth-child(1) > p:nth-child(1) > a").contents().get()[1];
18+
const grandPrix: string = $(grandPrixAll).text();
19+
const driverName: string = $(this).find("td:nth-child(2) > p:nth-child(1) > span:nth-child(1)").text().trim();
1920
const car: string = $(this).find("td:nth-child(3) > p:nth-child(1)").text().trim();
2021
const time: string = $(this).find("td:nth-child(4) > p:nth-child(1)").text().trim();
2122

22-
const driver: string = driverFirstName.concat(" ", driverLastName);
23+
const driver: string = driverName.slice(0, driverName.length - 3);
2324

2425
if (driver.length !== 0 && grandPrix.length !== 0 && car.length !== 0 && time.length !== 0) {
2526
const fastestLap: isFastestLap = {

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// export { getFastestLaps } from "./scraper/fastest-laps";
1+
export { getFastestLaps } from "./scraper/fastest-laps";
22
export { getDriverLineup } from "./scraper/driver-lineup";
33
// export { getTeamLineup } from "./scraper/team-lineup";
44
// export { getDriverStandings } from "./scraper/driver-standings";

0 commit comments

Comments
 (0)