A lightweight parser with XPath support, Scrapy-like Items, and flexible output options.
Project description
lightparser
A lightweight parsing library inspired by Scrapy.
Features
- Scrapy-like 'Selector' object for Xpath parsing.
- Lightweight 'Item' class for structured data.
- Automatic CSV/JSON export via '-o' or '-O' argument.
- '-O' argument to overwrite the existing file.
- '-o' argument to append the existing file.
- No framework lock-in.
Installation
pip install lightparser
Usage
import requests
from lightparser import Selector, Item, yield_item
response = requests.get("https://example.com")
selector = Selector(response.text)
for product in selector.xpath('//div[@class="product"]'):
item = Item()
item["title"] = product.xpath(".//h2/text()").get()
item["price"] = product.xpath(".//span[@class='price']/text()").get()
yield_item(item)
Command-line Usage
python my_script.py -o output.csv
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
lightparser-0.1.3.tar.gz
(3.1 kB
view details)
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 lightparser-0.1.3.tar.gz.
File metadata
- Download URL: lightparser-0.1.3.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45c0b6a170c89998b11d9eaa72ba381b84854adf99bf7f1fbb3972151f374724
|
|
| MD5 |
103da52eaff3c60de598805c90adb96b
|
|
| BLAKE2b-256 |
255e434f7673f4917a222bc90d8e34bb3a75c389fab1a92502a33dbc73b6f26e
|
File details
Details for the file lightparser-0.1.3-py3-none-any.whl.
File metadata
- Download URL: lightparser-0.1.3-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1e1b0b1c41892d0612f83e44c0fb9583fc4d3d89a49d965a1b4cea71ab6c14d
|
|
| MD5 |
60a93b892a1fb27185e1898c157bbd53
|
|
| BLAKE2b-256 |
e230b204ef98af933a2ce4a3cec3fced31de5b19ba97ab9dd367636ee35819d9
|