gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

Serialize form elements #195

Closed whybin closed 6 years ago

whybin commented 6 years ago

Adds functionality to handle form element serialization. serialize() and serializeArray() mimic their jQuery counterparts in terms of output. As the { name, value } format is less useful for most Python applications, this PR introduces formats compatible with, e.g., the Requests library:

I have added documentation and passing tests (whose results agree with jQuery 3.3.1).

Note that this includes a minor fix for the root() method, and strips newlines when querying the value of non-radio, non-checkbox input elements.