https://github.com/blacktrue/csf-sat-scraper
A PHP library to scrape CSF PDFs from SAT Mexico website.
https://github.com/blacktrue/csf-sat-scraper
Last synced: 5 months ago
JSON representation
A PHP library to scrape CSF PDFs from SAT Mexico website.
- Host: GitHub
- URL: https://github.com/blacktrue/csf-sat-scraper
- Owner: blacktrue
- Created: 2025-12-01T03:31:33.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-12-01T23:20:00.000Z (7 months ago)
- Last Synced: 2025-12-03T12:41:26.210Z (7 months ago)
- Language: PHP
- Size: 31.3 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CSF SAT Scraper
Un scraper en PHP para descargar constancias de situación fiscal del SAT México.
### Instalación
```bash
composer install blacktrue/csf-sat-scraper
```
### Uso Básico
```php
[
CURLOPT_SSL_CIPHER_LIST => 'DEFAULT@SECLEVEL=1',
],
RequestOptions::VERIFY => false,
]);
$captchaSolver = new ConsoleResolver();
$scraper = new Scraper(
$client,
$captchaSolver,
'TU_RFC',
'TU_CONTRASEÑA'
);
$pdfContent = $scraper->download();
file_put_contents('constancia.pdf', $pdfContent);
```
## 🧪 Testing
### Ejecutar Tests
```bash
# Todos los tests
composer test
# Con formato legible
vendor/bin/phpunit --testdox
# Sin cobertura (más rápido)
vendor/bin/phpunit --no-coverage
# Test específico
vendor/bin/phpunit tests/Unit/Services/CaptchaServiceTest.php
```
### Cobertura de Código
```bash
composer test-coverage
open coverage/index.html
```
## 🛠️ Desarrollo
### Requisitos
- PHP 8.4+
- Composer
- Extensión cURL
### Dependencias Principales
- `guzzlehttp/guzzle` - Cliente HTTP
- `symfony/dom-crawler` - Parsing de HTML
- `phpcfdi/image-captcha-resolver` - Resolución de captchas
### Dependencias de Desarrollo
- `phpunit/phpunit` ^10.0 - Framework de testing
## 🔧 Servicios
### AuthenticationService
Maneja todo el proceso de autenticación:
- Inicialización de login
- Obtención del formulario
- Envío de credenciales
- Verificación de sesión
### CaptchaService
Resuelve el captcha del SAT:
- Extracción de imagen del HTML
- Resolución con el solver configurado
### SSOHandler
Gestiona el flujo SSO/SAML:
- Procesamiento de formularios SAML
- Manejo de iframes
- Redirecciones SSO
### DocumentService
Descarga el documento:
- Envío de formulario final
- Descarga del PDF
## 🤝 Contribuir
1. Fork el proyecto
2. Crea una rama para tu feature (`git checkout -b feature/AmazingFeature`)
3. Commit tus cambios (`git commit -m 'Add some AmazingFeature'`)
4. Push a la rama (`git push origin feature/AmazingFeature`)
5. Abre un Pull Request
### Ejecutar Tests Antes de PR
```bash
composer test
```
## 📝 Licencia
MIT License
## 👤 Autor
Cesar Aguilera - cesargnu29@gmail.com
## 🙏 Agradecimientos
- PhpCfdi por image-captcha-resolver
- Comunidad de PHP por las herramientas