Combine XPath, CSS Selectors and JSONPath for Web data extracting.
Project description
Combine XPath, CSS Selectors and JSONPath for Web data extracting.
Quickstarts
Installation
Install the stable version from PYPI.
pip install data-extractor
Or install the latest version from Github.
pip install git+https://github.com/linw1995/data_extractor.git@master
Usage
from data_extractor import Field, Item, JSONExtractor
class Count(Item):
followings = Field(JSONExtractor("countFollowings"))
fans = Field(JSONExtractor("countFans"))
class User(Item):
name_ = Field(JSONExtractor("name"), name="name")
age = Field(JSONExtractor("age"), default=17)
count = Count()
assert User(JSONExtractor("data.users[*]"), is_many=True).extract(
{
"data": {
"users": [
{
"name": "john",
"age": 19,
"countFollowings": 14,
"countFans": 212,
},
{
"name": "jack",
"description": "",
"countFollowings": 54,
"countFans": 312,
},
]
}
}
) == [
{"name": "john", "age": 19, "count": {"followings": 14, "fans": 212}},
{"name": "jack", "age": 17, "count": {"followings": 54, "fans": 312}},
]
Changelog
v0.6.1
d28fff4 Fix:Item created error by type function. (Issue #56)
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
data_extractor-0.6.1.tar.gz
(12.0 kB
view hashes)
Built Distribution
Close
Hashes for data_extractor-0.6.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c76415ddfbce9fe5fd8a2c22f7d4b8dd64f4ffb64214510b6ffba39328f9ad8 |
|
MD5 | 5ef2756596d11e99b4c6db1e46a95598 |
|
BLAKE2b-256 | 2c8c7872093c5113c56c34196c43b61382fc7e08b7fb17a7f5de74dec70e7461 |