@strkfarm/sdk 1.0.36 → 1.0.38

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.
@@ -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
-