@strkfarm/sdk 1.0.36 → 1.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.browser.global.js +14845 -7267
- package/package.json +1 -2
- package/src/node/headless.node.ts +0 -36
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strkfarm/sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.37",
|
|
4
4
|
"description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -65,7 +65,6 @@
|
|
|
65
65
|
"inquirer": "^10.1.2",
|
|
66
66
|
"node-telegram-bot-api": "^0.66.0",
|
|
67
67
|
"proxy-from-env": "^1.1.0",
|
|
68
|
-
"puppeteer": "^24.4.0",
|
|
69
68
|
"redis": "^4.7.0",
|
|
70
69
|
"stacktrace-js": "^2.0.2",
|
|
71
70
|
"starknet": "^6.11.0",
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const puppeteer = require('puppeteer');
|
|
2
|
-
|
|
3
|
-
export async function getAPIUsingHeadlessBrowser(
|
|
4
|
-
url: string
|
|
5
|
-
) {
|
|
6
|
-
|
|
7
|
-
try {
|
|
8
|
-
// Launch a headless browser
|
|
9
|
-
const browser = await puppeteer.launch({ headless: true });
|
|
10
|
-
const page = await browser.newPage();
|
|
11
|
-
|
|
12
|
-
// Set a realistic User-Agent to avoid suspicion
|
|
13
|
-
await page.setUserAgent(
|
|
14
|
-
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
// Go to the API endpoint
|
|
18
|
-
await page.goto(url, {
|
|
19
|
-
waitUntil: 'networkidle2', // Wait until the page fully loads (including JS challenge)
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// If the API returns JSON, extract it
|
|
23
|
-
const jsonData = await page.evaluate(() => {
|
|
24
|
-
const pre = document.querySelector('pre'); // Adjust based on how the API response is formatted
|
|
25
|
-
return pre && pre.textContent ? JSON.parse(pre.textContent) : null;
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Clean up
|
|
29
|
-
await browser.close();
|
|
30
|
-
return jsonData;
|
|
31
|
-
} catch (error) {
|
|
32
|
-
console.error('Error:', error);
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|