-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
56 lines (50 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const fetch = require('node-fetch');
const fs = require('fs');
const path = require('path');
const url = 'https://vanikacodez.tech';
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`error http ka: ${response.status}`);
}
return response.text();
})
.then(data => {
fs.writeFile('idk.html', data, (err) => {
if (err) {
console.log(`error agaya: ${err.message}`);
} else {
console.log('cloned html');
}
});
const cssRegex = /href="(.*?\.css)"/gm;
const match = cssRegex.exec(data);
if (match && match[1]) {
const cssUrl = new URL(match[1], url);
// Fetch CSS file
fetch(cssUrl)
.then(response => {
if (!response.ok) {
throw new Error(`error : ${response.status}`);
}
return response.text();
})
.then(cssData => {
fs.writeFile('styles.css', cssData, (err) => {
if (err) {
console.log(`error: ${err.message}`);
} else {
console.log('cloned css');
}
});
})
.catch(error => {
console.log(`Error fetching CSS file: ${error.message}`);
});
} else {
console.log('No CSS file found');
}
})
.catch(error => {
console.log(`website he bhi?: ${error.message}`);
});