Added parsing for vins
parent
f52cd359ae
commit
9bc932a90b
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,12 @@
|
|||||||
|
const _ = require('lodash');
|
||||||
|
module.exports = function(config) {
|
||||||
|
return async function (page) {
|
||||||
|
const vinSelector = config.vinElementSelector;
|
||||||
|
const vinRegex = /(?<vin>A\d\w\d{3}\w\d{6})/i;
|
||||||
|
const possibleVinElements = await page.$$(vinSelector);
|
||||||
|
const evaluatedVinElements = await Promise.all(possibleVinElements.map(async element => await page.evaluate(el => el.textContent, element)));
|
||||||
|
const correctElement = _.find(evaluatedVinElements, element => vinRegex.test(element));
|
||||||
|
|
||||||
|
return correctElement ? vinRegex.exec(correctElement).groups.vin : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue