llm-search-tools 1.1.0
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/LICENSE +21 -0
- package/README.md +244 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/integration.test.d.ts +1 -0
- package/dist/integration.test.js +237 -0
- package/dist/modules/answerbox.test.d.ts +1 -0
- package/dist/modules/answerbox.test.js +105 -0
- package/dist/modules/autocomplete.d.ts +11 -0
- package/dist/modules/autocomplete.js +159 -0
- package/dist/modules/autocomplete.test.d.ts +1 -0
- package/dist/modules/autocomplete.test.js +188 -0
- package/dist/modules/common.d.ts +26 -0
- package/dist/modules/common.js +263 -0
- package/dist/modules/common.test.d.ts +1 -0
- package/dist/modules/common.test.js +87 -0
- package/dist/modules/crawl.d.ts +9 -0
- package/dist/modules/crawl.js +117 -0
- package/dist/modules/crawl.test.d.ts +1 -0
- package/dist/modules/crawl.test.js +48 -0
- package/dist/modules/events.d.ts +8 -0
- package/dist/modules/events.js +129 -0
- package/dist/modules/events.test.d.ts +1 -0
- package/dist/modules/events.test.js +104 -0
- package/dist/modules/finance.d.ts +10 -0
- package/dist/modules/finance.js +20 -0
- package/dist/modules/finance.test.d.ts +1 -0
- package/dist/modules/finance.test.js +77 -0
- package/dist/modules/flights.d.ts +8 -0
- package/dist/modules/flights.js +135 -0
- package/dist/modules/flights.test.d.ts +1 -0
- package/dist/modules/flights.test.js +128 -0
- package/dist/modules/hackernews.d.ts +8 -0
- package/dist/modules/hackernews.js +87 -0
- package/dist/modules/hackernews.js.map +1 -0
- package/dist/modules/images.test.d.ts +1 -0
- package/dist/modules/images.test.js +145 -0
- package/dist/modules/integrations.test.d.ts +1 -0
- package/dist/modules/integrations.test.js +93 -0
- package/dist/modules/media.d.ts +11 -0
- package/dist/modules/media.js +132 -0
- package/dist/modules/media.test.d.ts +1 -0
- package/dist/modules/media.test.js +186 -0
- package/dist/modules/news.d.ts +3 -0
- package/dist/modules/news.js +39 -0
- package/dist/modules/news.test.d.ts +1 -0
- package/dist/modules/news.test.js +88 -0
- package/dist/modules/parser.d.ts +19 -0
- package/dist/modules/parser.js +361 -0
- package/dist/modules/parser.test.d.ts +1 -0
- package/dist/modules/parser.test.js +151 -0
- package/dist/modules/reddit.d.ts +21 -0
- package/dist/modules/reddit.js +107 -0
- package/dist/modules/scrape.d.ts +16 -0
- package/dist/modules/scrape.js +272 -0
- package/dist/modules/scrape.test.d.ts +1 -0
- package/dist/modules/scrape.test.js +232 -0
- package/dist/modules/scraper.d.ts +12 -0
- package/dist/modules/scraper.js +640 -0
- package/dist/modules/scrapers/anidb.d.ts +8 -0
- package/dist/modules/scrapers/anidb.js +156 -0
- package/dist/modules/scrapers/duckduckgo.d.ts +6 -0
- package/dist/modules/scrapers/duckduckgo.js +284 -0
- package/dist/modules/scrapers/google-news.d.ts +2 -0
- package/dist/modules/scrapers/google-news.js +60 -0
- package/dist/modules/scrapers/google.d.ts +6 -0
- package/dist/modules/scrapers/google.js +211 -0
- package/dist/modules/scrapers/searxng.d.ts +2 -0
- package/dist/modules/scrapers/searxng.js +93 -0
- package/dist/modules/scrapers/thetvdb.d.ts +3 -0
- package/dist/modules/scrapers/thetvdb.js +147 -0
- package/dist/modules/scrapers/tmdb.d.ts +3 -0
- package/dist/modules/scrapers/tmdb.js +172 -0
- package/dist/modules/scrapers/yahoo-finance.d.ts +2 -0
- package/dist/modules/scrapers/yahoo-finance.js +33 -0
- package/dist/modules/search.d.ts +5 -0
- package/dist/modules/search.js +45 -0
- package/dist/modules/search.js.map +1 -0
- package/dist/modules/search.test.d.ts +1 -0
- package/dist/modules/search.test.js +219 -0
- package/dist/modules/urbandictionary.d.ts +12 -0
- package/dist/modules/urbandictionary.js +26 -0
- package/dist/modules/webpage.d.ts +4 -0
- package/dist/modules/webpage.js +150 -0
- package/dist/modules/webpage.js.map +1 -0
- package/dist/modules/wikipedia.d.ts +5 -0
- package/dist/modules/wikipedia.js +85 -0
- package/dist/modules/wikipedia.js.map +1 -0
- package/dist/scripts/interactive-search.d.ts +1 -0
- package/dist/scripts/interactive-search.js +98 -0
- package/dist/test.d.ts +1 -0
- package/dist/test.js +179 -0
- package/dist/test.js.map +1 -0
- package/dist/testBraveSearch.d.ts +1 -0
- package/dist/testBraveSearch.js +34 -0
- package/dist/testDuckDuckGo.d.ts +1 -0
- package/dist/testDuckDuckGo.js +52 -0
- package/dist/testEcosia.d.ts +1 -0
- package/dist/testEcosia.js +57 -0
- package/dist/testSearchModule.d.ts +1 -0
- package/dist/testSearchModule.js +95 -0
- package/dist/testwebpage.d.ts +1 -0
- package/dist/testwebpage.js +81 -0
- package/dist/types.d.ts +174 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/createTestDocx.d.ts +1 -0
- package/dist/utils/createTestDocx.js +58 -0
- package/dist/utils/htmlcleaner.d.ts +20 -0
- package/dist/utils/htmlcleaner.js +172 -0
- package/docs/README.md +275 -0
- package/docs/autocomplete.md +73 -0
- package/docs/crawling.md +88 -0
- package/docs/events.md +58 -0
- package/docs/examples.md +158 -0
- package/docs/finance.md +60 -0
- package/docs/flights.md +71 -0
- package/docs/hackernews.md +121 -0
- package/docs/media.md +87 -0
- package/docs/news.md +75 -0
- package/docs/parser.md +197 -0
- package/docs/scraper.md +347 -0
- package/docs/search.md +106 -0
- package/docs/wikipedia.md +91 -0
- package/package.json +97 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const readline = __importStar(require("readline"));
|
|
37
|
+
const google_1 = require("../modules/scrapers/google");
|
|
38
|
+
const duckduckgo_1 = require("../modules/scrapers/duckduckgo");
|
|
39
|
+
const searxng_1 = require("../modules/scrapers/searxng");
|
|
40
|
+
const rl = readline.createInterface({
|
|
41
|
+
input: process.stdin,
|
|
42
|
+
output: process.stdout
|
|
43
|
+
});
|
|
44
|
+
const searchEngine = async (name, searchFn, query) => {
|
|
45
|
+
try {
|
|
46
|
+
console.log(`\n🔍 Searching ${name}...`);
|
|
47
|
+
const results = await searchFn(query, { limit: 3 });
|
|
48
|
+
console.log(`\n✅ ${name} Results:`);
|
|
49
|
+
if (results.length === 0) {
|
|
50
|
+
console.log(' No results found.');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
results.slice(0, 3).forEach((result, index) => {
|
|
54
|
+
console.log(` ${index + 1}. ${result.title}`);
|
|
55
|
+
console.log(` ${result.url}`);
|
|
56
|
+
if (result.snippet)
|
|
57
|
+
console.log(` "${result.snippet.substring(0, 100)}..."`);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
let errorMessage;
|
|
63
|
+
if (error instanceof Error) {
|
|
64
|
+
errorMessage = error.message;
|
|
65
|
+
}
|
|
66
|
+
else if (typeof error === 'object' && error !== null) {
|
|
67
|
+
try {
|
|
68
|
+
errorMessage = JSON.stringify(error, null, 2);
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
errorMessage = String(error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
errorMessage = String(error);
|
|
76
|
+
}
|
|
77
|
+
console.log(`\n❌ ${name} Failed: ${errorMessage}`);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
console.log("Welcome to the LLM-Search-Tools Interactive Tester!");
|
|
81
|
+
console.log("This tool will search DuckDuckGo, Google, and SearxNG for your query.");
|
|
82
|
+
rl.question('\n👉 Enter what to search: ', async (query) => {
|
|
83
|
+
if (!query.trim()) {
|
|
84
|
+
console.log("Empty query, exiting.");
|
|
85
|
+
rl.close();
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
console.log(`\n🚀 Starting search for: "${query}"...`);
|
|
89
|
+
// Run sequentially to keep output clean, or parallel?
|
|
90
|
+
// Parallel might mix output. Let's do parallel but capture output, or just sequential for readability.
|
|
91
|
+
// User asked to "search all search engines", sequential is fine and cleaner for reading.
|
|
92
|
+
await searchEngine('DuckDuckGo', duckduckgo_1.searchDuckDuckGo, query);
|
|
93
|
+
await searchEngine('Google', google_1.searchGoogle, query);
|
|
94
|
+
await searchEngine('SearxNG', searxng_1.searchSearxNG, query);
|
|
95
|
+
console.log("\n✨ All searches completed!");
|
|
96
|
+
rl.close();
|
|
97
|
+
process.exit(0);
|
|
98
|
+
});
|
package/dist/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// test.ts - test all the things cuz we're responsible devs... kinda
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
// get random item from array
|
|
8
|
+
function getRandomItem(arr) {
|
|
9
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
10
|
+
}
|
|
11
|
+
// delay helper
|
|
12
|
+
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
13
|
+
// test parsing all files in test/files directory
|
|
14
|
+
async function testParser() {
|
|
15
|
+
console.log('\n📝 PARSER MODULE TEST');
|
|
16
|
+
console.log('-------------------');
|
|
17
|
+
const testFilesDir = (0, path_1.join)(process.cwd(), 'test', 'files');
|
|
18
|
+
const files = (0, fs_1.readdirSync)(testFilesDir);
|
|
19
|
+
for (const file of files) {
|
|
20
|
+
const filePath = (0, path_1.join)(testFilesDir, file);
|
|
21
|
+
console.log(`\nTesting file: ${file}`);
|
|
22
|
+
try {
|
|
23
|
+
const result = await (0, index_1.parse)(filePath, {
|
|
24
|
+
csv: { columns: true },
|
|
25
|
+
language: 'eng',
|
|
26
|
+
xml: {
|
|
27
|
+
ignoreAttributes: false,
|
|
28
|
+
parseAttributeValue: true
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
console.log('File type:', result.type);
|
|
32
|
+
console.log('Metadata:', JSON.stringify(result.metadata, null, 2));
|
|
33
|
+
if (result.data) {
|
|
34
|
+
console.log('Data sample:', JSON.stringify(result.data?.slice?.(0, 2) || result.data, null, 2));
|
|
35
|
+
}
|
|
36
|
+
// Show preview of text content
|
|
37
|
+
const textPreview = result.text.slice(0, 200) + (result.text.length > 200 ? '...' : '');
|
|
38
|
+
console.log('Text preview:', textPreview);
|
|
39
|
+
console.log('✅ Successfully parsed');
|
|
40
|
+
}
|
|
41
|
+
catch (err) {
|
|
42
|
+
const error = err;
|
|
43
|
+
console.warn(`⚠️ Failed to parse ${file}:`, error.message);
|
|
44
|
+
if (error.code) {
|
|
45
|
+
console.warn('Error code:', error.code);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function runTests() {
|
|
51
|
+
console.log('🔍 starting tests...\n');
|
|
52
|
+
try {
|
|
53
|
+
// test scraper module
|
|
54
|
+
console.log('📖 SCRAPER MODULE TEST');
|
|
55
|
+
console.log('---------------------');
|
|
56
|
+
console.log('\n1. Basic Search Results:');
|
|
57
|
+
const searchResults = await (0, index_1.search)('typescript programming');
|
|
58
|
+
console.log(JSON.stringify(searchResults, null, 2));
|
|
59
|
+
await delay(3000);
|
|
60
|
+
console.log('\n2. Google Search Results:');
|
|
61
|
+
const googleResults = await (0, index_1.searchGoogle)('react hooks');
|
|
62
|
+
console.log(JSON.stringify(googleResults, null, 2));
|
|
63
|
+
await delay(3000);
|
|
64
|
+
console.log('\n3. DuckDuckGo Search Results:');
|
|
65
|
+
const ddgResults = await (0, index_1.searchDuckDuckGo)('node.js async');
|
|
66
|
+
console.log(JSON.stringify(ddgResults, null, 2));
|
|
67
|
+
await delay(3000);
|
|
68
|
+
console.log('\n4. Search with Puppeteer Forced:');
|
|
69
|
+
const puppeteerResults = await (0, index_1.search)('web scraping', {
|
|
70
|
+
forcePuppeteer: true,
|
|
71
|
+
limit: 5
|
|
72
|
+
});
|
|
73
|
+
console.log(JSON.stringify(puppeteerResults, null, 2));
|
|
74
|
+
await delay(5000);
|
|
75
|
+
console.log('\n5. Search with Proxy (if available):');
|
|
76
|
+
// Example proxy config - replace with actual proxy for testing
|
|
77
|
+
const proxyConfig = {
|
|
78
|
+
type: 'http',
|
|
79
|
+
host: 'proxy.example.com',
|
|
80
|
+
port: 8080,
|
|
81
|
+
auth: {
|
|
82
|
+
username: 'user',
|
|
83
|
+
password: 'pass'
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
// Only test proxy if you have one available
|
|
87
|
+
// const proxyResults = await search('test query', {
|
|
88
|
+
// proxy: proxyConfig,
|
|
89
|
+
// limit: 3
|
|
90
|
+
// });
|
|
91
|
+
// console.log(JSON.stringify(proxyResults, null, 2));
|
|
92
|
+
console.log('Proxy test skipped - configure proxy to test');
|
|
93
|
+
await delay(3000);
|
|
94
|
+
// test wikipedia module
|
|
95
|
+
console.log('\n\n📚 WIKIPEDIA MODULE TEST');
|
|
96
|
+
console.log('----------------------');
|
|
97
|
+
console.log('\n1. Wikipedia Search Results:');
|
|
98
|
+
const wikiResults = await (0, index_1.wikiSearch)('Node.js');
|
|
99
|
+
console.log(JSON.stringify(wikiResults, null, 2));
|
|
100
|
+
if (wikiResults.length > 0) {
|
|
101
|
+
await delay(1000);
|
|
102
|
+
console.log('\n2. Wikipedia Article Content:');
|
|
103
|
+
const content = await (0, index_1.wikiGetContent)(wikiResults[0].title);
|
|
104
|
+
console.log(content.substring(0, 500) + '...');
|
|
105
|
+
await delay(1000);
|
|
106
|
+
console.log('\n3. Wikipedia Article Summary:');
|
|
107
|
+
const summary = await (0, index_1.wikiGetSummary)(wikiResults[0].title);
|
|
108
|
+
console.log(JSON.stringify(summary, null, 2));
|
|
109
|
+
}
|
|
110
|
+
// Add delay before next module
|
|
111
|
+
await delay(2000);
|
|
112
|
+
// test hackernews module
|
|
113
|
+
console.log('\n\n💻 HACKER NEWS MODULE TEST');
|
|
114
|
+
console.log('------------------------');
|
|
115
|
+
console.log('\n1. Top Stories:');
|
|
116
|
+
const topStories = await (0, index_1.getTopStories)(5);
|
|
117
|
+
console.log(JSON.stringify(topStories, null, 2));
|
|
118
|
+
await delay(500);
|
|
119
|
+
console.log('\n2. New Stories:');
|
|
120
|
+
const newStories = await (0, index_1.getNewStories)(5);
|
|
121
|
+
console.log(JSON.stringify(newStories, null, 2));
|
|
122
|
+
await delay(500);
|
|
123
|
+
console.log('\n3. Best Stories:');
|
|
124
|
+
const bestStories = await (0, index_1.getBestStories)(5);
|
|
125
|
+
console.log(JSON.stringify(bestStories, null, 2));
|
|
126
|
+
await delay(500);
|
|
127
|
+
console.log('\n4. Ask HN Stories:');
|
|
128
|
+
const askStories = await (0, index_1.getAskStories)(5);
|
|
129
|
+
console.log(JSON.stringify(askStories, null, 2));
|
|
130
|
+
await delay(500);
|
|
131
|
+
console.log('\n5. Show HN Stories:');
|
|
132
|
+
const showStories = await (0, index_1.getShowStories)(5);
|
|
133
|
+
console.log(JSON.stringify(showStories, null, 2));
|
|
134
|
+
await delay(500);
|
|
135
|
+
console.log('\n6. Job Stories:');
|
|
136
|
+
const jobStories = await (0, index_1.getJobStories)(5);
|
|
137
|
+
console.log(JSON.stringify(jobStories, null, 2));
|
|
138
|
+
if (topStories.length > 0) {
|
|
139
|
+
await delay(500);
|
|
140
|
+
console.log('\n7. Single Story Details:');
|
|
141
|
+
const storyId = parseInt(topStories[0].url.split('id=')[1]);
|
|
142
|
+
const story = await (0, index_1.getStoryById)(storyId);
|
|
143
|
+
console.log(JSON.stringify(story, null, 2));
|
|
144
|
+
}
|
|
145
|
+
// Add delay before next module
|
|
146
|
+
await delay(2000);
|
|
147
|
+
// test webpage module
|
|
148
|
+
console.log('\n\n📄 WEBPAGE MODULE TEST');
|
|
149
|
+
console.log('--------------------');
|
|
150
|
+
const testUrl = 'https://example.com';
|
|
151
|
+
console.log(`\n1. Testing URL: ${testUrl}`);
|
|
152
|
+
const isAccessible = await (0, index_1.isUrlAccessible)(testUrl);
|
|
153
|
+
console.log('\nURL Accessibility:', isAccessible);
|
|
154
|
+
if (isAccessible) {
|
|
155
|
+
console.log('\n2. Webpage Content:');
|
|
156
|
+
const content = await (0, index_1.getWebpageContent)(testUrl);
|
|
157
|
+
console.log(JSON.stringify(content, null, 2));
|
|
158
|
+
await delay(1000);
|
|
159
|
+
console.log('\n3. Webpage Text:');
|
|
160
|
+
const text = await (0, index_1.getWebpageText)(testUrl);
|
|
161
|
+
console.log(text);
|
|
162
|
+
}
|
|
163
|
+
// Add delay before parser tests
|
|
164
|
+
await delay(2000);
|
|
165
|
+
// test parser module with all test files
|
|
166
|
+
await testParser();
|
|
167
|
+
console.log('\n\n🎉 ALL TESTS COMPLETED SUCCESSFULLY!\n');
|
|
168
|
+
}
|
|
169
|
+
catch (err) {
|
|
170
|
+
const error = err;
|
|
171
|
+
console.error('\n❌ TEST FAILED:', {
|
|
172
|
+
message: error.message,
|
|
173
|
+
code: error.code,
|
|
174
|
+
details: error.originalError
|
|
175
|
+
});
|
|
176
|
+
process.exit(1);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
runTests();
|
package/dist/test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";AAAA,oEAAoE;;AAEpE,mCAiBiB;AAEjB,6BAA6B;AAC7B,SAAS,aAAa,CAAI,GAAQ;IAChC,OAAO,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,KAAK,UAAU,QAAQ;IACrB,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IAEtC,IAAI,CAAC;QACH,qBAAqB;QACrB,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QAEpC,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC;QAC5C,MAAM,aAAa,GAAG,MAAM,IAAA,cAAM,EAAC,YAAY,CAAC,CAAC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-0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// test brave search separately
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const search_1 = require("./modules/search");
|
|
5
|
+
async function testBraveSearch() {
|
|
6
|
+
try {
|
|
7
|
+
console.log('🔍 Testing Brave Search...\n');
|
|
8
|
+
const query = 'typescript programming';
|
|
9
|
+
console.log(`Searching for: "${query}"`);
|
|
10
|
+
const results = await (0, search_1.search)(query, {
|
|
11
|
+
provider: 'brave',
|
|
12
|
+
limit: 5,
|
|
13
|
+
safeSearch: true
|
|
14
|
+
});
|
|
15
|
+
if (results.length === 0) {
|
|
16
|
+
console.log('No results found');
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
console.log(`\nFound ${results.length} results:`);
|
|
20
|
+
results.forEach((result, index) => {
|
|
21
|
+
console.log(`\n${index + 1}. ${result.title}`);
|
|
22
|
+
console.log(` URL: ${result.url}`);
|
|
23
|
+
if (result.snippet) {
|
|
24
|
+
console.log(` Snippet: ${result.snippet}`);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
console.error('\n❌ Test failed:', err);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
testBraveSearch().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Test DuckDuckGo search in isolation
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const search_1 = require("./modules/search");
|
|
5
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
async function testDuckDuckGo() {
|
|
7
|
+
try {
|
|
8
|
+
console.log('🔍 Testing DuckDuckGo Search...\n');
|
|
9
|
+
// Test regular search
|
|
10
|
+
const query = 'typescript programming';
|
|
11
|
+
console.log(`1. Regular Search for: "${query}"`);
|
|
12
|
+
const results = await (0, search_1.search)(query, {
|
|
13
|
+
provider: 'duckduckgo',
|
|
14
|
+
limit: 5
|
|
15
|
+
});
|
|
16
|
+
if (results.length === 0) {
|
|
17
|
+
console.log('No results found');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(`\nFound ${results.length} results:`);
|
|
21
|
+
results.forEach((result, index) => {
|
|
22
|
+
console.log(`\n${index + 1}. ${result.title}`);
|
|
23
|
+
console.log(` URL: ${result.url}`);
|
|
24
|
+
if (result.snippet) {
|
|
25
|
+
console.log(` Snippet: ${result.snippet}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Wait before safe search test
|
|
30
|
+
await delay(5000);
|
|
31
|
+
console.log('\n2. SafeSearch Test');
|
|
32
|
+
const safeResults = await (0, search_1.search)('adult content', {
|
|
33
|
+
provider: 'duckduckgo',
|
|
34
|
+
limit: 3,
|
|
35
|
+
safeSearch: true
|
|
36
|
+
});
|
|
37
|
+
console.log('\nSafe Search Results:');
|
|
38
|
+
safeResults.forEach((result, index) => {
|
|
39
|
+
console.log(`\n${index + 1}. ${result.title}`);
|
|
40
|
+
});
|
|
41
|
+
console.log('\n✅ DuckDuckGo tests completed successfully!');
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const error = err;
|
|
45
|
+
console.error('\n❌ Test failed:', error.message);
|
|
46
|
+
if (error.code === 'DDG_SEARCH_ERROR') {
|
|
47
|
+
console.log('\nTip: DuckDuckGo has strict rate limits. Try waiting a few minutes before retrying.');
|
|
48
|
+
}
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
testDuckDuckGo().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Test Ecosia search in isolation
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const search_1 = require("./modules/search");
|
|
5
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
async function testEcosiaSearch() {
|
|
7
|
+
try {
|
|
8
|
+
console.log('🔍 Testing Ecosia Search...\n');
|
|
9
|
+
// Test regular search
|
|
10
|
+
const query = 'typescript programming';
|
|
11
|
+
console.log(`1. Regular Search for: "${query}"`);
|
|
12
|
+
const results = await (0, search_1.search)(query, {
|
|
13
|
+
provider: 'ecosia',
|
|
14
|
+
limit: 5
|
|
15
|
+
});
|
|
16
|
+
if (results.length === 0) {
|
|
17
|
+
console.log('No results found');
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log(`\nFound ${results.length} results:`);
|
|
21
|
+
results.forEach((result, index) => {
|
|
22
|
+
console.log(`\n${index + 1}. ${result.title}`);
|
|
23
|
+
console.log(` URL: ${result.url}`);
|
|
24
|
+
if (result.snippet) {
|
|
25
|
+
console.log(` Snippet: ${result.snippet}`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
// Test different search term
|
|
30
|
+
await delay(2000);
|
|
31
|
+
console.log('\n2. Different Search Term Test');
|
|
32
|
+
const secondResults = await (0, search_1.search)('web development', {
|
|
33
|
+
provider: 'ecosia',
|
|
34
|
+
limit: 3
|
|
35
|
+
});
|
|
36
|
+
console.log('\nSearch Results:');
|
|
37
|
+
secondResults.forEach((result, index) => {
|
|
38
|
+
console.log(`\n${index + 1}. ${result.title}`);
|
|
39
|
+
console.log(` URL: ${result.url}`);
|
|
40
|
+
});
|
|
41
|
+
console.log('\n✅ Ecosia tests completed successfully!');
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const error = err;
|
|
45
|
+
console.error('\n❌ Test failed:', error.message);
|
|
46
|
+
if (error.code === 'ECOSIA_SEARCH_ERROR') {
|
|
47
|
+
console.log('\nError details:', error.originalError?.message || 'Unknown error');
|
|
48
|
+
console.log('\nTips:');
|
|
49
|
+
console.log('1. Check if Ecosia is accessible in your region');
|
|
50
|
+
console.log('2. Verify your internet connection');
|
|
51
|
+
console.log('3. Try adjusting the delay between requests');
|
|
52
|
+
}
|
|
53
|
+
console.log('\nFull error:', JSON.stringify(error, null, 2));
|
|
54
|
+
process.exit(1);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
testEcosiaSearch().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Test search module separately to handle different rate limits
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const index_1 = require("./index");
|
|
5
|
+
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
async function testSearch() {
|
|
7
|
+
try {
|
|
8
|
+
console.log("📖 SEARCH MODULE TESTING");
|
|
9
|
+
console.log("----------------------");
|
|
10
|
+
const testQuery = "typescript programming";
|
|
11
|
+
const testLimit = 3;
|
|
12
|
+
// Test Google
|
|
13
|
+
console.log("\n1. Google Search Results:");
|
|
14
|
+
const googleResults = await (0, index_1.search)(testQuery, {
|
|
15
|
+
provider: 'google',
|
|
16
|
+
limit: testLimit
|
|
17
|
+
});
|
|
18
|
+
console.log("Found", googleResults.length, "Google results");
|
|
19
|
+
console.log(JSON.stringify(googleResults, null, 2));
|
|
20
|
+
// Test Brave with delay
|
|
21
|
+
await delay(3000);
|
|
22
|
+
console.log("\nWaiting before Brave search...");
|
|
23
|
+
console.log("\n2. Brave Search Results:");
|
|
24
|
+
const braveResults = await (0, index_1.search)(testQuery, {
|
|
25
|
+
provider: 'brave',
|
|
26
|
+
limit: testLimit
|
|
27
|
+
});
|
|
28
|
+
console.log("Found", braveResults.length, "Brave results");
|
|
29
|
+
console.log(JSON.stringify(braveResults, null, 2));
|
|
30
|
+
// Test Ecosia with delay
|
|
31
|
+
await delay(3000);
|
|
32
|
+
console.log("\nWaiting before Ecosia search...");
|
|
33
|
+
console.log("\n3. Ecosia Search Results:");
|
|
34
|
+
const ecosiaResults = await (0, index_1.search)(testQuery, {
|
|
35
|
+
provider: 'ecosia',
|
|
36
|
+
limit: testLimit
|
|
37
|
+
});
|
|
38
|
+
console.log("Found", ecosiaResults.length, "Ecosia results");
|
|
39
|
+
console.log(JSON.stringify(ecosiaResults, null, 2));
|
|
40
|
+
// Test DuckDuckGo with longer delay
|
|
41
|
+
await delay(5000);
|
|
42
|
+
console.log("\nWaiting before DuckDuckGo search...");
|
|
43
|
+
console.log("\n4. DuckDuckGo Search Results:");
|
|
44
|
+
try {
|
|
45
|
+
const ddgResults = await (0, index_1.search)(testQuery, {
|
|
46
|
+
provider: 'duckduckgo',
|
|
47
|
+
limit: testLimit
|
|
48
|
+
});
|
|
49
|
+
console.log("Found", ddgResults.length, "DuckDuckGo results");
|
|
50
|
+
console.log(JSON.stringify(ddgResults, null, 2));
|
|
51
|
+
// Test SafeSearch features
|
|
52
|
+
await delay(5000);
|
|
53
|
+
console.log("\n5. SafeSearch Tests:");
|
|
54
|
+
// Test DuckDuckGo SafeSearch
|
|
55
|
+
console.log("\na) DuckDuckGo with SafeSearch:");
|
|
56
|
+
const ddgSafeResults = await (0, index_1.search)("adult content", {
|
|
57
|
+
provider: 'duckduckgo',
|
|
58
|
+
limit: 1,
|
|
59
|
+
safeSearch: true
|
|
60
|
+
});
|
|
61
|
+
console.log("DuckDuckGo SafeSearch result:", ddgSafeResults.length ? ddgSafeResults[0].title : "No results");
|
|
62
|
+
// Test Ecosia (always safe)
|
|
63
|
+
await delay(3000);
|
|
64
|
+
console.log("\nb) Ecosia Search (always safe):");
|
|
65
|
+
const ecosiaSafeResults = await (0, index_1.search)("adult content", {
|
|
66
|
+
provider: 'ecosia',
|
|
67
|
+
limit: 1
|
|
68
|
+
});
|
|
69
|
+
console.log("Ecosia filtered result:", ecosiaSafeResults.length ? ecosiaSafeResults[0].title : "No results");
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
const error = err;
|
|
73
|
+
console.log("DuckDuckGo search failed (rate limiting):", error.message);
|
|
74
|
+
console.log("\nTry running search providers separately:");
|
|
75
|
+
console.log("- npm run test-ddg");
|
|
76
|
+
console.log("- npm run test-brave");
|
|
77
|
+
console.log("\nNote: Search providers have different rate limits:");
|
|
78
|
+
console.log("- DuckDuckGo: 5 seconds between requests");
|
|
79
|
+
console.log("- Ecosia: 2 seconds between requests");
|
|
80
|
+
console.log("- Brave/Google: 1 second between requests");
|
|
81
|
+
}
|
|
82
|
+
console.log("\n✅ Search module tests completed!");
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
const error = err;
|
|
86
|
+
console.error("\n❌ TEST FAILED:", {
|
|
87
|
+
message: error.message,
|
|
88
|
+
code: error.code,
|
|
89
|
+
details: error.originalError,
|
|
90
|
+
});
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Run tests
|
|
95
|
+
testSearch().catch(console.error);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// ah yes, the test file... where we make sure this actually works n stuff
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const webpage_1 = require("./modules/webpage");
|
|
5
|
+
// just print stuff nicely ya know
|
|
6
|
+
function printResult(title, content) {
|
|
7
|
+
console.log('\n' + '='.repeat(50));
|
|
8
|
+
console.log(`${title}:`);
|
|
9
|
+
console.log('='.repeat(50));
|
|
10
|
+
if (typeof content === 'string') {
|
|
11
|
+
console.log(content);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.log('Title:', content.title);
|
|
15
|
+
console.log('Excerpt:', content.excerpt);
|
|
16
|
+
console.log('Length:', content.length);
|
|
17
|
+
console.log('Site Name:', content.siteName || 'N/A');
|
|
18
|
+
console.log('Favicon:', content.faviconUrl || 'N/A');
|
|
19
|
+
if (content.assets && content.assets.length > 0) {
|
|
20
|
+
console.log('\nAssets found:');
|
|
21
|
+
content.assets.forEach(asset => {
|
|
22
|
+
console.log(`- ${asset.type}: ${asset.url} (${asset.alt || 'no alt text'})`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
console.log('\nFull Content:');
|
|
26
|
+
console.log(content.textContent);
|
|
27
|
+
if (content.markdown) {
|
|
28
|
+
console.log('\nFull Markdown:');
|
|
29
|
+
console.log(content.markdown);
|
|
30
|
+
}
|
|
31
|
+
if (content.content) {
|
|
32
|
+
console.log('\nFull HTML Content:');
|
|
33
|
+
console.log(content.content);
|
|
34
|
+
}
|
|
35
|
+
if (content.processedHtml) {
|
|
36
|
+
console.log('\nProcessed HTML:');
|
|
37
|
+
console.log(content.processedHtml);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
// actually test the stuff
|
|
42
|
+
async function runTests() {
|
|
43
|
+
try {
|
|
44
|
+
const url = process.argv[2];
|
|
45
|
+
if (!url) {
|
|
46
|
+
console.log('yo, gimme a url to test! like: npm run test-webpage https://example.com');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
// lets try to get the content even if the url seems inaccessible
|
|
50
|
+
// some sites block HEAD requests but still work fine
|
|
51
|
+
console.log('checking if url is accessible...');
|
|
52
|
+
const isAccessible = await (0, webpage_1.isUrlAccessible)(url);
|
|
53
|
+
if (!isAccessible) {
|
|
54
|
+
console.log('heads up: url seems blocked, but well try anyway...');
|
|
55
|
+
}
|
|
56
|
+
// test getting content
|
|
57
|
+
console.log('\ntesting content extraction...');
|
|
58
|
+
try {
|
|
59
|
+
const content = await (0, webpage_1.getWebpageContent)(url);
|
|
60
|
+
printResult('Page Content', content);
|
|
61
|
+
}
|
|
62
|
+
catch (err) {
|
|
63
|
+
console.log('failed to get content:', err);
|
|
64
|
+
}
|
|
65
|
+
// test getting just the text
|
|
66
|
+
console.log('\ntesting text-only extraction...');
|
|
67
|
+
try {
|
|
68
|
+
const textContent = await (0, webpage_1.getWebpageText)(url);
|
|
69
|
+
printResult('Text-only Content', textContent);
|
|
70
|
+
}
|
|
71
|
+
catch (err) {
|
|
72
|
+
console.log('failed getting text:', err);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (err) {
|
|
76
|
+
console.error('something went really wrong:', err);
|
|
77
|
+
process.exit(1);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// lets do this!
|
|
81
|
+
runTests().catch(console.error);
|