-
Notifications
You must be signed in to change notification settings - Fork 4
/
README
47 lines (36 loc) · 1.42 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
ABOUT
Python 2.x bindings for Parsley. Tested with Python 2.5 and 2.6.
INSTALLATION
= Get Parsley and Dependancies =
Download Parsley from http://github.com/fizx/parsley/tree/master following the installation directions located at http://github.com/fizx/parsley/blob/master/INSTALL
For Python 2.5, the simplejson library is required. For Python 2.6 and later, the stdlib json library is used.
= Install pyparsely =
sudo python setup.py install
= Example Code =
from pyparsley import PyParsley
# Valid options (all are named arguments):
#
# Requires one of:
# 'file' -- the input file path or url
# 'string' -- the input string
#
# And optionally (default is the first listed value):
# 'input' => ['html', 'xml']
# 'output' => ['python', 'json', 'xml']
# 'prune' => [true, false]
# 'collate' => [true, false]
# 'base' => 'http://some/base/href'
# 'allow_net' => [true, false]
# 'allow_local' => [true, false]
parselet = PyParsley({
"title": "title",
"links(a)": [
{
"name": ".",
"href": "@href"
}
]
})
json_string = parselet.parse(file = some_file, output = "json")
# Using Parsley's builtin URI fetching.
json_string = parselet.parse(file = "http://www.example.com/", output = "json")