Mythus commited on
Commit
24b2ef7
·
verified ·
1 Parent(s): dd39f46

Create run.js

Browse files
Files changed (1) hide show
  1. run.js +53 -0
run.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const http = require('http');
2
+ const https = require('https');
3
+
4
+ const url = 'https://d000d.com/e/9b3w45p3h2gz';
5
+
6
+ const headers = {
7
+ 'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:127.0) Gecko/20100101 Firefox/127.0',
8
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8',
9
+ 'Accept-Language': 'en-US,en;q=0.5',
10
+ 'DNT': '1',
11
+ 'Sec-GPC': '1',
12
+ 'Connection': 'keep-alive',
13
+ 'Cookie': 'file_id=66308942; aff=37046; ref_url=; lang=1',
14
+ 'Upgrade-Insecure-Requests': '1',
15
+ 'Sec-Fetch-Dest': 'document',
16
+ 'Sec-Fetch-Mode': 'navigate',
17
+ 'Sec-Fetch-Site': 'cross-site',
18
+ 'Priority': 'u=1',
19
+ 'Pragma': 'no-cache',
20
+ 'Cache-Control': 'no-cache'
21
+ };
22
+
23
+ const options = {
24
+ method: 'GET',
25
+ headers: headers
26
+ };
27
+
28
+ const fetchPage = (url) => {
29
+ const client = url.startsWith('https') ? https : http;
30
+
31
+ client.get(url, options, (res) => {
32
+ let data = '';
33
+
34
+ if (res.statusCode !== 200) {
35
+ console.error(`Failed to fetch the page. Status code: ${res.statusCode}`);
36
+ return;
37
+ }
38
+
39
+ res.on('data', (chunk) => {
40
+ data += chunk;
41
+ });
42
+
43
+ res.on('end', () => {
44
+ console.log('Page content fetched successfully.');
45
+ console.log(data);
46
+ });
47
+ }).on('error', (err) => {
48
+ console.error(`An error occurred while requesting ${url}.`);
49
+ console.error(`Exception: ${err.message}`);
50
+ });
51
+ };
52
+
53
+ fetchPage(url);