-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_algora.js
More file actions
58 lines (47 loc) · 1.74 KB
/
Copy pathparse_algora.js
File metadata and controls
58 lines (47 loc) · 1.74 KB
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
57
58
const { chromium } = require('playwright');
(async () => {
const browser = await chromium.launch({ headless: true });
const page = await browser.newPage({ viewport: { width: 1920, height: 3000 } });
await page.goto('https://algora.io/bounties', { waitUntil: 'networkidle', timeout: 30000 });
await page.waitForTimeout(3000);
// Get all text content
const bodyText = await page.innerText('body');
// Split by $ to find all prices
const lines = bodyText.split('\n');
let inBounty = false;
let bounties = [];
let currentBounty = {};
for (const line of lines) {
const trimmed = line.trim();
if (!trimmed) continue;
const priceMatch = trimmed.match(/^\$(\d+)/);
const hashMatch = trimmed.match(/#(\d+)/);
const langMatch = trimmed.match(/\((\d+)\)/);
if (priceMatch) {
currentBounty.price = '$' + priceMatch[1];
}
if (hashMatch) {
currentBounty.hash = '#' + hashMatch[1];
}
if (langMatch && !trimmed.includes('Bounties') && !trimmed.includes('Sign')) {
currentBounty.lang = trimmed;
}
// Accumulate title
if (currentBounty.price && !currentBounty.hash && !currentBounty.lang && !priceMatch && trimmed.length > 5) {
currentBounty.title = (currentBounty.title || '') + ' ' + trimmed;
}
// End of bounty - save it
if (currentBounty.price && currentBounty.title && trimmed.match(/^\d/)) {
if (currentBounty.title) {
currentBounty.title = currentBounty.title.trim();
bounties.push({...currentBounty});
}
currentBounty = { price: currentBounty.price };
}
}
console.log('=== ALL BOUNTIES ===');
for (const b of bounties) {
console.log(JSON.stringify(b));
}
await browser.close();
})();