FastParser 🚀
A high-performance, asynchronous content parser that supports both HTML and PDF extraction with special handling for arXiv papers.
✨ Features
- 🚄 Asynchronous content fetching
- 📄 PDF extraction support
- 🌐 HTML parsing
- 📚 Special handling for arXiv URLs
- 📦 Batch processing capability
- 🔄 Progress tracking with tqdm
🛠️ Installation
pip install fastparser
# Dependencies
pip install aiohttp PyPDF2 tqdm
🚀 Quick Start
from fastparser import parse
# Single URL parsing
text = parse("https://example.com")
# Batch processing
urls = [
"https://example.com",
"https://arxiv.org/abs/2301.01234",
"https://example.com/document.pdf"
]
texts = parse(urls)
📖 Detailed Usage
Basic Parser Configuration
from fastparser import FastParser
# Initialize with PDF extraction (default: True)
parser = FastParser(extract_pdf=True)
# Single URL
content = parser.fetch("https://example.com")
# Multiple URLs
contents = parser.fetch_batch([
"https://example.com",
"https://arxiv.org/abs/2301.01234"
])
Working with arXiv Papers
The parser automatically handles different arXiv URL formats:
parser = FastParser()
# These will be automatically converted to appropriate formats
urls = [
"https://arxiv.org/abs/2301.01234", # Will fetch PDF if extract_pdf=True
"http://arxiv.org/html/2301.01234", # Will fetch HTML or PDF based on settings
]
contents = parser.fetch_batch(urls)
PDF-Only Processing
parser = FastParser(extract_pdf=True)
pdf_urls = [
"https://example.com/document.pdf",
"https://arxiv.org/pdf/2301.01234.pdf"
]
pdf_contents = parser.fetch_batch(pdf_urls)
🔧 API Reference
FastParser Class
class FastParser:
def __init__(self, extract_pdf: bool = True)
def fetch(self, url: str) -> str
def fetch_batch(self, urls: list) -> list
def __call__(self, urls: str|list) -> str|list
Main Functions
parse(urls: str|list) -> str|list: Convenience function for quick parsing_async_html_parser(urls: list): Internal async processing method_fetch_pdf_content(pdf_urls: list): Internal PDF processing method_arxiv_url_fix(url: str): Internal arXiv URL formatting method
⚡ Performance
The parser uses asynchronous operations for optimal performance:
- Concurrent URL fetching
- Batch processing capabilities
- Progress tracking with tqdm
- Memory-efficient PDF processing
🔍 Example: Advanced Usage
import asyncio
from fastparser import FastParser
async def process_large_dataset():
parser = FastParser(extract_pdf=True)
# Process URLs in batches
all_urls = ["url1", "url2", ..., "url1000"]
batch_size = 50
results = []
for i in range(0, len(all_urls), batch_size):
batch = all_urls[i:i + batch_size]
batch_results = parser.fetch_batch(batch)
results.extend(batch_results)
return results
# Run with asyncio
results = asyncio.run(process_large_dataset())
⚠️ Error Handling
The parser includes robust error handling:
- Failed URL fetches return empty strings
- PDF processing errors are caught gracefully
- HTTP status checks
- Invalid URL format handling
🤝 Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
📝 Dependencies
aiohttp: Async HTTP client/server frameworkPyPDF2: PDF processing librarytqdm: Progress bar library- Custom
FastHTMLParserV3module
📋 TODO
- Add support for more document types
- Implement caching mechanism
- Add timeout configurations
- Improve error reporting
- Add proxy support
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by [Your Name]
Metadata
Release files for parselite 0.3.13
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| parselite-0.3.13.tar.gz | 7.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| parselite-0.3.13-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 14.6 kB
Release files / parselite-0.3.13.tar.gz
| Download URL | parselite-0.3.13.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66e6dba1369600cfc36399749578472e7dcae1ed94e2dba8e22512848e2b26fe
|
|
BLAKE2b-256 checksum How to use checksums |
e373d0c8969257e8b1ee3a617824af24cddf29a7f8d1d1cfbe4f73ebde9625ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.0rc1
|
Release files / parselite-0.3.13-py3-none-any.whl
| Download URL | parselite-0.3.13-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d9838092cb2a3ca3b76c94d9063dc1b1706a742f07bbcf6fc8a644c002eb6ea0
|
|
BLAKE2b-256 checksum How to use checksums |
19c90122bdb8e17492e49d48f11efe31965630ac96ed3033477db45761db5b8f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.11.0rc1
|
Security for parselite 0.3.13
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.