Initial commit
This commit is contained in:
commit
cca18066a1
23
README.md
Normal file
23
README.md
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
# Initialisation :
|
||||||
|
|
||||||
|
- npm i
|
||||||
|
|
||||||
|
# Utilisation :
|
||||||
|
|
||||||
|
- node index.js <ref>
|
||||||
|
|
||||||
|
# Problème =>
|
||||||
|
|
||||||
|
- Si le headless ne fonctionne pas, se rendre à la ligne 28 du fichier index.js et passer le "headless: true" en "headless: false".
|
||||||
|
|
||||||
|
Sinon contactez moi sur discord : lantium#9204
|
||||||
|
|
||||||
|
## Pour Cécile =>
|
||||||
|
|
||||||
|
Pour les processeurs :
|
||||||
|
|
||||||
|
- node index.js DXBVJM1 | grep PRC | awk -F ',' '{ print $2 }'
|
||||||
|
|
||||||
|
Pour le chassis :
|
||||||
|
|
||||||
|
- node index.js DXBVJM1 | grep CHAS | awk -F ',' '{ print $5 }'
|
3
config.js
Normal file
3
config.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
URL : "https://www.dell.com/support/home/fr-fr", // URL du site du jeu
|
||||||
|
}
|
68
index.js
Normal file
68
index.js
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
const puppeteer = require("puppeteer-extra");
|
||||||
|
const pluginStealth = require("puppeteer-extra-plugin-stealth");
|
||||||
|
const path = require("path");
|
||||||
|
const downloadPath = path.resolve("./Result");
|
||||||
|
const fs = require("fs");
|
||||||
|
|
||||||
|
const { URL } = require("./config");
|
||||||
|
|
||||||
|
puppeteer.use(pluginStealth());
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
var dateTime = require("node-datetime");
|
||||||
|
var dt = dateTime.create();
|
||||||
|
var formattedDate = dt.format("d-m-Y H:M:S");
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
`Je démarre le programme ( Scrapper Dell ) by Lantium , ${formattedDate}`
|
||||||
|
);
|
||||||
|
|
||||||
|
var dir = __dirname + "/Result";
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, 0744);
|
||||||
|
}
|
||||||
|
|
||||||
|
const answer = process.argv.slice(2);
|
||||||
|
|
||||||
|
const browser = await puppeteer.launch({ headless: true });
|
||||||
|
const page1 = await browser.newPage();
|
||||||
|
await page1.setViewport({ width: 1920, height: 1080 });
|
||||||
|
await page1.goto(`${URL}`);
|
||||||
|
await page1.waitForSelector("#inpEntrySelection");
|
||||||
|
await page1.click("#inpEntrySelection");
|
||||||
|
|
||||||
|
await page1.keyboard.type(`${answer}`);
|
||||||
|
await page1.waitForSelector("#txtSearchEs");
|
||||||
|
await page1.click("#txtSearchEs");
|
||||||
|
await page1.waitForTimeout(5000);
|
||||||
|
|
||||||
|
await page1.waitForSelector("#quicklink-sysconfig");
|
||||||
|
|
||||||
|
await page1.click("#quicklink-sysconfig");
|
||||||
|
|
||||||
|
await page1.waitForTimeout(5000);
|
||||||
|
await page1.waitForSelector("#current-config-export");
|
||||||
|
await page1._client.send("Page.setDownloadBehavior", {
|
||||||
|
behavior: "allow",
|
||||||
|
downloadPath: downloadPath,
|
||||||
|
});
|
||||||
|
await page1.click("#current-config-export");
|
||||||
|
await page1.waitForTimeout(5000);
|
||||||
|
await browser.close();
|
||||||
|
|
||||||
|
const csv = require("csv-parser");
|
||||||
|
const results = [];
|
||||||
|
const parser = fs
|
||||||
|
.createReadStream(`${downloadPath}/${answer}.csv`)
|
||||||
|
.pipe(csv());
|
||||||
|
parser.on("data", (data) => results.push(data));
|
||||||
|
parser.on("end", () => {
|
||||||
|
console.log('Processeur')
|
||||||
|
console.log(results.filter((record) => record.Description.includes("PRC")));
|
||||||
|
console.log('#############################################################');
|
||||||
|
console.log('Chassis')
|
||||||
|
console.log(results.filter((record) => record.Description.includes("CHAS")));
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
})();
|
1608
package-lock.json
generated
Normal file
1608
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
18
package.json
Normal file
18
package.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "scrapper",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Scrapper reference dell",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "lantium",
|
||||||
|
"license": "ISC",
|
||||||
|
"dependencies": {
|
||||||
|
"csv-parser": "^3.0.0",
|
||||||
|
"node-datetime": "^2.1.2",
|
||||||
|
"puppeteer": "^13.1.1",
|
||||||
|
"puppeteer-extra": "^3.1.18",
|
||||||
|
"puppeteer-extra-plugin-stealth": "^2.7.8"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user