-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-tenderflow.js
More file actions
158 lines (139 loc) · 5.23 KB
/
Copy pathtest-tenderflow.js
File metadata and controls
158 lines (139 loc) · 5.23 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Test tenderflow.co.za and similar aggregation sites
const https = require('https');
const http = require('http');
async function testUrl(url, label) {
console.log(`🔍 Testing ${label}: ${url}`);
try {
const startTime = Date.now();
const response = await new Promise((resolve, reject) => {
const client = url.startsWith('https') ? https : http;
const req = client.get(url, { timeout: 10000 }, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => resolve({
status: res.statusCode,
data,
headers: res.headers,
finalUrl: res.responseUrl || url
}));
});
req.on('error', reject);
req.on('timeout', () => {
req.destroy();
reject(new Error('Request timeout'));
});
});
const endTime = Date.now();
const responseTime = endTime - startTime;
if (response.status === 200) {
const tenderKeywords = ['tender', 'bid', 'rfq', 'rfp', 'procurement', 'quotation'];
const hasTenderContent = tenderKeywords.some(keyword =>
response.data.toLowerCase().includes(keyword)
);
console.log(` ✅ ${responseTime}ms | ${response.data.length} bytes | Tender: ${hasTenderContent ? 'YES' : 'NO'}`);
if (hasTenderContent) {
// Look for reference numbers
const refPattern = /\b([A-Z]{2,10}[\s\/\-]\d{2,6}[\s\/\-]\d{4}(?:[\/\-]\d{2,4})?|(?:BID|RFQ|RFP|EOI|SCM|QUO|TEN)[\s\/\-]?(?:NO\.?\s*)?[A-Z0-9\/\-]{4,20})\b/gi;
const refs = response.data.match(refPattern) || [];
console.log(` 📋 Found ${refs.length} reference numbers`);
if (refs.length > 0) {
console.log(` 📝 Sample refs: ${refs.slice(0, 3).join(', ')}`);
}
// Check if it's an aggregation site (multiple sources mentioned)
const sources = ['department', 'municipality', 'province', 'government', 'entity'];
const isAggregator = sources.some(source =>
response.data.toLowerCase().includes(source)
);
console.log(` 🌐 Aggregator: ${isAggregator ? 'YES' : 'NO'}`);
}
return { success: true, hasTenderContent, refCount: refs.length };
} else {
console.log(` ❌ HTTP ${response.status}`);
return { success: false, status: response.status };
}
} catch (error) {
console.log(` ❌ ERROR: ${error.message}`);
return { success: false, error: error.message };
}
}
async function testAggregationSites() {
console.log('🧪 Testing tender aggregation sites...\n');
// Test tenderflow.co.za and similar sites
const aggregationSites = [
{
label: 'TenderFlow',
url: 'https://www.tenderflow.co.za',
description: 'South African tender aggregation platform'
},
{
label: 'Tender Bulletin',
url: 'https://www.tenderbulletin.co.za',
description: 'Tender notice aggregation service'
},
{
label: 'Tender SA',
url: 'https://www.tendersa.co.za',
description: 'South African tender portal'
},
{
label: 'Online Tenders',
url: 'https://www.onlinetenders.co.za',
description: 'Online tender notices'
},
{
label: 'Tender News',
url: 'https://www.tendernews.co.za',
description: 'Tender news and notices'
},
{
label: 'Tender Watch',
url: 'https://www.tenderwatch.co.za',
description: 'Tender monitoring service'
},
{
label: 'SA Tenders',
url: 'https://www.satenders.co.za',
description: 'South African tender listings'
},
{
label: 'Tender Portal SA',
url: 'https://www.tenderportal.co.za',
description: 'Tender portal for South Africa'
},
{
label: 'Tender Connect',
url: 'https://www.tenderconnect.co.za',
description: 'Tender connection platform'
},
{
label: 'Tender Central',
url: 'https://www.tendercentral.co.za',
description: 'Central tender platform'
}
];
const results = [];
for (const site of aggregationSites) {
console.log(`\n📡 ${site.label} (${site.description}):`);
const result = await testUrl(site.url, site.label);
results.push({ ...site, ...result });
// Small delay between requests
await new Promise(resolve => setTimeout(resolve, 500));
}
// Summary
console.log('\n📊 AGGREGATION SITES SUMMARY:');
const successful = results.filter(r => r.success);
const withTenderContent = successful.filter(r => r.hasTenderContent);
const aggregators = withTenderContent.filter(r => r.isAggregator);
console.log(`✅ Total sites tested: ${results.length}`);
console.log(`✅ Accessible: ${successful.length}`);
console.log(`📋 With tender content: ${withTenderContent.length}`);
console.log(`🌐 Aggregators: ${aggregators.length}`);
if (withTenderContent.length > 0) {
console.log('\n🎯 SUCCESSFUL AGGREGATION SITES:');
withTenderContent.forEach(site => {
console.log(` ${site.label}: ${site.url} | ${site.refCount} refs`);
});
}
return results;
}
testAggregationSites();