Fast, simple, and beautifully minimal web scraping
Project description
🚀 quickfetch - Quick Fetch
Fast, simple, and beautifully minimal web scraping.
✨ The Problem
Python developers who need to grab HTML or JSON from the web must currently:
- Import
requeststo fetch content - Import
BeautifulSouporlxmlto parse HTML - Write 6–10 lines of boilerplate code just to get basic data
This is slow, repetitive, and messy for quick scripts.
🎯 The Solution
quickfetch makes web scraping a 1–2 line task with auto-detection of HTML/JSON content.
🚀 Quick Start
Installation
pip install quickfetch
Basic Usage
from quickfetch import get
# Fetch a webpage
page = get("https://example.com")
print(page.select("h1").text) # Get first h1 text
print(page.links) # Get all links
print(page.images) # Get all images
# Fetch JSON API
data = get("https://api.github.com/users/octocat")
print(data.json["name"]) # Access JSON data directly
🎨 Features
Core Features
get(url)→ Returns a response object with:.html→ Raw HTML content (if HTML response).json→ Parsed JSON data (if JSON response).select(css_selector)→ CSS selector matching.xpath(xpath_expr)→ XPath expression matching.links→ All hyperlinks on the page.images→ All image URLs on the page
Auto-Detection
quickfetch automatically detects if the response is HTML or JSON:
# HTML page
page = get("https://example.com")
print(page.html) # Raw HTML
print(page.json) # None
# JSON API
data = get("https://api.github.com/users/octocat")
print(data.html) # None
print(data.json) # Parsed JSON dict
CSS Selectors
page = get("https://example.com")
# Get first element
title = page.select("h1")[0].text
# Get all elements
links = page.select("a[href]")
for link in links:
print(link.text, link["href"])
# Nested selection
articles = page.select("article")
for article in articles:
title = article.select("h2")[0].text
content = article.select("p")[0].text
XPath Support
page = get("https://example.com")
# XPath expressions
elements = page.xpath("//h1[@class='title']")
for elem in elements:
print(elem.text)
Link & Image Extraction
page = get("https://example.com")
# Get all links
all_links = page.links
print(f"Found {len(all_links)} links")
# Get all images
all_images = page.images
print(f"Found {len(all_images)} images")
Element Properties
page = get("https://example.com")
element = page.select("a")[0]
print(element.text) # Text content
print(element.html) # HTML content
print(element.attrs) # All attributes
print(element["href"]) # Specific attribute
📚 Examples
Scraping News Headlines
from quickfetch import get
# Get headlines from a news site
page = get("https://news.ycombinator.com")
headlines = page.select(".titleline > a")
for headline in headlines[:5]:
print(f"• {headline.text}")
print(f" {headline['href']}\n")
API Data Extraction
from quickfetch import get
# Get GitHub user data
user = get("https://api.github.com/users/octocat")
data = user.json
print(f"Name: {data['name']}")
print(f"Location: {data['location']}")
print(f"Followers: {data['followers']}")
Image Gallery Scraper
from quickfetch import get
# Get all images from a gallery
page = get("https://example.com/gallery")
images = page.images
print("Found images:")
for img_url in images:
print(f" {img_url}")
Form Data Extraction
from quickfetch import get
# Get form fields
page = get("https://example.com/contact")
forms = page.select("form")
for form in forms:
inputs = form.select("input")
for input_elem in inputs:
name = input_elem.get("name", "")
type_attr = input_elem.get("type", "text")
print(f"Input: {name} ({type_attr})")
🔧 Advanced Usage
Custom Headers
from quickfetch import get
# Add custom headers
page = get("https://api.example.com",
headers={"User-Agent": "MyBot/1.0"})
Error Handling
from quickfetch import get
try:
page = get("https://example.com")
if page.html:
print("Successfully fetched HTML")
elif page.json:
print("Successfully fetched JSON")
else:
print("No content found")
except Exception as e:
print(f"Error: {e}")
Batch Processing
from quickfetch import get
urls = [
"https://example1.com",
"https://example2.com",
"https://example3.com"
]
for url in urls:
page = get(url)
title = page.select("title")[0].text if page.select("title") else "No title"
print(f"{url}: {title}")
📦 Installation
From PyPI
pip install quickfetch
From Source
git clone https://github.com/quickfetch/quickfetch.git
cd quickfetch
pip install -e .
🛠 Dependencies
- requests ≥ 2.25.0 - HTTP library
- selectolax ≥ 0.3.0 - Fast HTML parser
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with requests for HTTP
- Powered by selectolax for HTML parsing
- Inspired by the need for simpler web scraping workflows
Made with ❤️ for Python developers who just want to get things done quickly.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quickfetch-0.1.0.tar.gz.
File metadata
- Download URL: quickfetch-0.1.0.tar.gz
- Upload date:
- Size: 8.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
730f2c06b15e5abca6e472f3d5ad37157ec1e0823128161436267194a4978f43
|
|
| MD5 |
fb79b8e4909056799be6499956129c26
|
|
| BLAKE2b-256 |
e71bc27357c1e42127dec9b9687a0f5ed99be1bc7baa76ad23e3a070654e89f7
|
File details
Details for the file quickfetch-0.1.0-py3-none-any.whl.
File metadata
- Download URL: quickfetch-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cb16a0286988916fdb191f9e1a5d4366358f31f6c74cee677b0ca5bc24cfb49
|
|
| MD5 |
1420b8cd62d8dd1fc2ba99ed844d92ce
|
|
| BLAKE2b-256 |
16b0d5426344166bf2f6d065e23ff30dfb7307560a87eebb67bc47d412b5a481
|