In a similar post a question was asked about changing a form value from [on] to not on, which was simply setting a 'True' and 'False' value (using Mechanize).
How would this be accomplished in scrapy FormRequest.from_response
?
EDIT
For example, using mechanize to get form information,
this is the default that comes with the webpage form.
By default, everything on the form is checked:
<CheckboxControl(ac=[*on])>
type=checkbox, name=ac value=['on']
<CheckboxControl(<None>=[*on])>
type=checkbox, name=None value=[]
<TextControl(p=)>
type=text, name=p value=
<CheckboxControl(pr[]=[*0, *1, *2])>
type=checkbox, name=pr[] value=['0', '1', '2']
<CheckboxControl(a[]=[*0, *1, *2, *3, *4])>
type=checkbox, name=a[] value=['0', '1', '2', '3', '4']
<CheckboxControl(pl=[*on])>
type=checkbox, name=pl value=['on']
<CheckboxControl(sp[]=[*1, *2, *3])>
type=checkbox, name=sp[] value=['1', '2', '3']
<SelectControl(pp=[0, 1, *2, 3])>
type=select, name=pp value=['2']
Note the 'ac', '<None>
' and 'pl'.
They have a value of [*on]
The goal is to turn them 'off'(?) (uncheck them)
FormRequest.from_response(response, formnumber=0, formdata={'pr[]': '2', 'sp[]': '3', 'pp': '3', 'a[]': ['3', '4']}))
This returns a form with the modified boxes per the formdata. Those keys not mentioned in the formdata are still checked.
Following the example in the above post:
FormRequest.from_response(response, formdata={'live': 'False'})
I have done the FormRequest with a variety of values: 'False', 'True', '', [''], 'on', 'off' and 'None' but can't seem to get the right response.
Any suggestions?
EDIT:
Have attempted:
FormRequest(url, formdata = {'pl': 'False'}, callback=parse_this)
FormRequest(url, formdata = {'pl': 'off'}, callback=parse_this)
FormRequest(url, formdata = {'pl': ''}, callback=parse_this)
FormRequest(url, formdata = {'pl': 'None'}, callback=parse_this)
FormRequest(url, formdata = {'pl': None}, callback=parse_this)
FormRequest.from_response(response, formdata = {'pl': 'False'})
FormRequest.from_response(response, formdata = {'pl': 'off'})
FormRequest.from_response(response, formdata = {'pl': '')
By default, the webpage provides a form that contains checkboxes that are already checked. The goal is submit the form and 'turn off' some checkbox that only have two options: 'on'/'off'