
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
@felinto-dev/felinto-connect-bot
Advanced tools
Uma biblioteca robusta para automação de navegadores usando Puppeteer com recursos avançados de tratamento de erros e retry automático.
Uma biblioteca robusta para automação de navegadores usando Puppeteer com recursos avançados de tratamento de erros e retry automático.
npm install felinto-connect-bot
import { newPage } from 'felinto-connect-bot';
// Uso simples
const page = await newPage({
initialUrl: 'https://example.com',
timeout: 30
});
// Com configurações de retry
const page = await newPage({
initialUrl: 'https://example.com',
retryOptions: {
maxRetries: 5,
baseDelay: 2000
}
});
interface newPageParams {
browserWSEndpoint?: string; // Endpoint do browser remoto
userAgent?: string; // User agent customizado
cookies?: Protocol.Network.CookieParam[]; // Cookies para definir
timeout?: number; // Timeout em segundos (padrão: 60)
initialUrl?: string; // URL inicial para navegar
navigationOptions?: GoToOptions; // Opções de navegação
blockedResourcesTypes?: Set<string>; // Tipos de recursos para bloquear
slowMo?: number; // Delay entre ações (ms)
$json?: any; // Configurações em formato JSON
retryOptions?: { // Configurações de retry
maxRetries?: number; // Máximo de tentativas (padrão: 3)
baseDelay?: number; // Delay base em ms (padrão: 1000)
};
}
O sistema de retry utiliza backoff exponencial e é aplicado automaticamente para:
// Configuração personalizada de retry
const page = await newPage({
initialUrl: 'https://site-instavel.com',
retryOptions: {
maxRetries: 5, // Tentará 5 vezes
baseDelay: 1500 // Delay inicial de 1.5s (1.5s, 3s, 6s, 12s, 24s)
}
});
A biblioteca inclui classes de erro específicas para diferentes cenários:
import {
BrowserConnectionError,
PageCreationError,
NavigationError,
AuthenticationError
} from 'felinto-connect-bot';
try {
const page = await newPage({ initialUrl: 'https://example.com' });
} catch (error) {
if (error instanceof BrowserConnectionError) {
console.log('Falha na conexão com o browser:', error.message);
} else if (error instanceof NavigationError) {
console.log('Falha na navegação:', error.message);
} else if (error instanceof PageCreationError) {
console.log('Falha ao criar página:', error.message);
} else if (error instanceof AuthenticationError) {
console.log('Falha na autenticação:', error.message);
}
}
# Obrigatórias
TWO_CAPTCHA_KEY=sua_chave_2captcha
# Opcionais - Browser
CHROME_HEADLESS_WS_URL=ws://localhost:9222
CHROME_HEADLESS_ARGS=--no-sandbox,--disable-dev-shm-usage
DEFAULT_CHROME_HEADLESS_WIDTH_SCREEN=1920
DEFAULT_CHROME_HEADLESS_HEIGHT_SCREEN=1080
# Opcionais - Proxy
PROXY_USERNAME=seu_usuario
PROXY_PASSWORD=sua_senha
# Ambiente
NODE_ENV=production|development
const page = await newPage({ initialUrl: 'https://example.com' });
// Tira screenshot e armazena automaticamente
await page.takeScreenshot();
// Acessa todos os screenshots tirados
import { screenshots } from 'felinto-connect-bot';
console.log(`Total de screenshots: ${screenshots.length}`);
const page = await newPage({
browserWSEndpoint: 'ws://chrome-server:9222',
userAgent: 'Mozilla/5.0 (custom)',
cookies: [
{ name: 'session', value: 'abc123', domain: '.example.com' }
],
timeout: 45,
initialUrl: 'https://example.com/login',
navigationOptions: {
waitUntil: 'networkidle0',
timeout: 30000
},
slowMo: 500,
retryOptions: {
maxRetries: 3,
baseDelay: 2000
}
});
const config = {
browserWSEndpoint: 'ws://localhost:9222',
productPageUrl: 'https://example.com',
browserUserAgent: 'Custom Bot 1.0',
cookies: [/* seus cookies */]
};
const page = await newPage({ $json: config });
page.close()
é simulado (não fecha realmente)CHROME_HEADLESS_WS_URL
ou browserWSEndpoint
git checkout -b feature/nova-feature
)git commit -m 'feat: adiciona nova feature'
)git push origin feature/nova-feature
)Este projeto está sob a licença MIT. Veja o arquivo LICENSE para mais detalhes.
FAQs
Uma biblioteca robusta para automação de navegadores usando Puppeteer com recursos avançados de tratamento de erros e retry automático.
We found that @felinto-dev/felinto-connect-bot demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.