A lightweight parser with XPath support, Scrapy-like Items, and flexible output options.
Project description
lightparser
A lightweight parsing library inspired by Scrapy.
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.2.tar.gz
(2.4 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.2.tar.gz.
File metadata
- Download URL: lightparser-0.1.2.tar.gz
- Upload date:
- Size: 2.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f643a9e6a39bc229a8379fb7bc2c735ec121475e29e137e5dab134f202425f9
|
|
| MD5 |
23223a847bdca5d68e33cac0011fa5c1
|
|
| BLAKE2b-256 |
9572cdb10b4fec9bca6be0dcd854c5edc445a94761aafacb8966ac80b3c97482
|
File details
Details for the file lightparser-0.1.2-py3-none-any.whl.
File metadata
- Download URL: lightparser-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.2 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 |
538c0cee3f889241bfd87550e9c8f9746f3c76d6762366aa1bd19836c1b08a75
|
|
| MD5 |
60113a1174c9ea0bc3b6537b0baee873
|
|
| BLAKE2b-256 |
00fc3b8cf9bf613b36c91b924f96a2f32a9e051b13981c98fe4a941e4860e38c
|