0

is there any library that does this ?

https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#constructing-the-form-data-set

Here an example of what i want to achieve:

data = """
<form action='/'> 
<input type='text' name='test'>
</form>
"""

x = buildformdata(data)

print(x)
{'test': ''}

I know how to create this using for ex. beatifulsoup, but maybe theres something done already? For example, what about converting code that Firefox or Chrome uses to build that data into python?

Here's some code that does this:

https://github.com/jmcarp/robobrowser/blob/master/robobrowser/forms/fields.py

https://github.com/jmcarp/robobrowser/blob/master/robobrowser/forms/form.py#L64

  • Similiar question https://stackoverflow.com/questions/30964568/how-to-get-a-key-value-data-set-from-a-html-form –  Dec 19 '17 at 11:19
  • Another one with javascript https://stackoverflow.com/questions/1184624/convert-form-data-to-javascript-object-with-jquery –  Dec 19 '17 at 11:33

1 Answers1

0

Heres source code from chromium :))

https://cs.chromium.org/chromium/build/third_party/zope/testing/formparser.py