generate selector schemas classes from dsl-like language based on python
Project description
Selector schema codegen
ssc_codegen - generator of parsers for various programming languages (for html priority) using python-DSL configurations with built-in declarative language.
Designed to port parsers to various programming languages and libs
Motivation
interesting in practice write DSL-like language- decrease boilerplate code for web-parsers
- write once - convert to other mainstream http parser libs
- minimal operations for easy add another libs and languages in future
- include css, xpath, attributes operations, regex, minimal string formatting operations
- pre validate css/xpath queries and logic before generate code
- standardisation: generate classes with minimal dependencies and documented parsed signature
Install
pipx (recommended for CLI usage)
pipx install ssc_codegen
pip
pip install ssc_codegen
Supported libs and languages
language | lib | xpath | css | formatter |
---|---|---|---|---|
python | bs4 | NO | YES | black |
- | parsel | YES | YES | - |
- | selectolax (modest) | NO | YES | - |
- | scrapy (based on parsel, but class init argument - Response) | YES | YES | - |
dart | universal_html | NO | YES | dart format |
Quickstart
see example and read code with comments
Recommendations
- usage css selector: they can be guaranteed converted to xpath (if target language not support CSS selectors)
- usage simple operations for more compatibility other libraries.
- Some libraries may not fully support selector specifications
- for example,
#product_description+ p
selector inparsel
works fine, but not works inselectolax
,dart
libs
- there is a xpath to css converter for simple queries without guarantees of functionality.
For example, in css there is no analogue of
contains
from xpath, etc.
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
ssc_codegen-0.2.4.tar.gz
(19.1 kB
view details)
Built Distribution
File details
Details for the file ssc_codegen-0.2.4.tar.gz
.
File metadata
- Download URL: ssc_codegen-0.2.4.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.4 Linux/5.15.0-79-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a276a0adea003489bccbec5e2260ea1b4ddfd0264dfd887f12d4597f1c0af9 |
|
MD5 | d93f025169fa382cf84fdffb5c411b73 |
|
BLAKE2b-256 | a6b77df927b40bd1ee625c7c74da6eb9c260c1b108420d2a1ec782cfe556afcd |
File details
Details for the file ssc_codegen-0.2.4-py3-none-any.whl
.
File metadata
- Download URL: ssc_codegen-0.2.4-py3-none-any.whl
- Upload date:
- Size: 37.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.11.4 Linux/5.15.0-79-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ce8bc83b60aa8bf6029054d77a33de77474a174c4596a36c344939d65afbb6f |
|
MD5 | 971c2e21b89fd0990f56024557f1e743 |
|
BLAKE2b-256 | 43c09123586024cf50a9a581b4c0f7b780a3690ba9ad931c3393410da73a807f |