Re-wrote broken Perv City scraper, added profile scraping.
This commit is contained in:
@@ -1,19 +1,25 @@
|
||||
'use strict';
|
||||
|
||||
function inchesToCm(inches) {
|
||||
if (!inches) return null;
|
||||
|
||||
return Math.round(Number(inches) * 2.54);
|
||||
}
|
||||
|
||||
function feetInchesToCm(feet, inches) {
|
||||
if (!feet && !inches) return null;
|
||||
|
||||
if (typeof feet === 'string' && !inches) {
|
||||
const [feetPart, inchesPart] = feet.match(/\d+/g);
|
||||
return feetInchesToCm(feetPart, inchesPart);
|
||||
return feetInchesToCm(Number(feetPart), Number(inchesPart));
|
||||
}
|
||||
|
||||
return Math.round((Number(feet) * 30.48) + (Number(inches) * 2.54));
|
||||
return Math.round((Number(feet) * 30.48) + ((Number(inches) || 0) * 2.54));
|
||||
}
|
||||
|
||||
function cmToFeetInches(centimeters) {
|
||||
if (!centimeters) return null;
|
||||
|
||||
const feet = Math.floor(centimeters / 30.48);
|
||||
const inches = Math.round((centimeters / 2.54) % (feet * 12));
|
||||
|
||||
@@ -21,18 +27,24 @@ function cmToFeetInches(centimeters) {
|
||||
}
|
||||
|
||||
function heightToCm(height) {
|
||||
if (!height) return null;
|
||||
|
||||
const [feet, inches] = height.match(/\d+/g);
|
||||
|
||||
return feetInchesToCm(feet, inches);
|
||||
}
|
||||
|
||||
function lbsToKg(lbs) {
|
||||
if (!lbs) return null;
|
||||
|
||||
const pounds = lbs.toString().match(/\d+/)[0];
|
||||
|
||||
return Math.round(Number(pounds) * 0.453592);
|
||||
}
|
||||
|
||||
function kgToLbs(kgs) {
|
||||
if (!kgs) return null;
|
||||
|
||||
const kilos = kgs.toString().match(/\d+/)[0];
|
||||
|
||||
return Math.round(Number(kilos) / 0.453592);
|
||||
|
||||
Reference in New Issue
Block a user