Skip to content

Commit 9ed46c1

Browse files
committed
formula one scraper - multiple url functionality started
1 parent fdec902 commit 9ed46c1

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

formulaOneScraper/formulaOneScraper.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,31 @@ const fetch = (...args) =>
88
async function getFormulaOneDrivers() {
99
console.log("Getting Formula One Drivers...");
1010

11-
const response = await fetch("https://www.formula1.com/en/drivers.html");
11+
const urls = [
12+
"https://www.formula1.com/en/latest.html",
13+
"https://www.formula1.com/en/results.html/2022/drivers.html",
14+
"https://www.formula1.com/en/results.html/2022/team.html",
15+
];
16+
17+
const url = "https://www.formula1.com/en/drivers.html";
18+
19+
const response = await fetch(url);
1220
const body = await response.text();
1321
const $ = cheerio.load(body);
1422

23+
// go through each url and get the body of the page
24+
const promises = urls.map(async (url) => {
25+
const response = await fetch(url);
26+
const body = await response.text();
27+
return body;
28+
});
29+
30+
const bodies = await Promise.all(promises);
31+
32+
bodies.map((body) => {
33+
console.log("BODY: ", body);
34+
});
35+
1536
// ============================================================================= \\
1637
// ============================================================================= \\
1738
// - - - - - - - - - - - C O R E L O G I C S T A R T - - - - - - - - - - - ||

0 commit comments

Comments
 (0)