Skip to content

Commit 6cefa02

Browse files
committed
formula one scraper started
1 parent 95efa42 commit 6cefa02

File tree

3 files changed

+44
-3
lines changed

3 files changed

+44
-3
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# all node_modules
12
node_modules
23

34
# all txt files
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
const cheerio = require("cheerio");
2+
3+
// work-around for "require" syntax from node-fetch";
4+
const fetch = (...args) =>
5+
import("node-fetch").then(({ default: fetch }) => fetch(...args));
6+
7+
async function getFormulaOneDrivers() {
8+
console.log("Getting Formula One Drivers...");
9+
10+
const response = await fetch("https://www.formula1.com/en/drivers.html");
11+
const body = await response.text();
12+
const $ = cheerio.load(body);
13+
14+
// const wrapper = $(".listing-items--wrapper");
15+
// console.log("WRAPPER: ", wrapper.length);
16+
17+
const items = [];
18+
19+
$(
20+
".listing-items--wrapper > .row > .col-12 > .listing-item--link > .listing-item--border > .container > .listing-item--head > .listing-item--name"
21+
).map((i, el) => {
22+
// insert space after first word
23+
const name = $(el).find(".f1-color--carbonBlack").text();
24+
console.log("NAME: ", name);
25+
});
26+
27+
try {
28+
} catch (error) {
29+
console.log("ERROR: ", error);
30+
}
31+
}
32+
getFormulaOneDrivers();

googleWebScrapers/package.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,22 @@
22
"name": "googlesearchblogscraper",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "googleSearchResults.js",
5+
"main": "index.js",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"keywords": [
1010
"web",
1111
"scraper",
12-
"webscraper"
12+
"webscraper",
13+
"google",
14+
"search",
15+
"blog",
16+
"scrape",
17+
"scraping",
18+
"node",
19+
"nodejs",
20+
"node.js"
1321
],
1422
"author": "Keith Hetrick",
1523
"license": "ISC",
@@ -20,4 +28,4 @@
2028
"pdfkit": "^0.13.0",
2129
"unirest": "^0.6.0"
2230
}
23-
}
31+
}

0 commit comments

Comments
 (0)