-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation #1
Conversation
…enctype and formenctype with a known unsupported value
Sometimes, you might want to prevent a value from a field from being included | ||
in the generated request data. For example, because the field is removed or | ||
disabled through JavaScript, or because the field or a parent element has the | ||
``disabled`` attribute (currently not supported by form2request): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL
|
||
.. _data: | ||
|
||
Setting form data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the docs and the explanations, great work! It's something which is currently missing in Scrapy's FormRequest docs.
Co-authored-by: Mikhail Korobov <kmike84@gmail.com>
…t/form-data support for the GET method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great @Gallaecio!
Implementation differences compared to Scrapy
While the code is heavily based on Scrapy’s, and intended to replace it in the future, it has some notable implementation differences worth pointing out for discussion:
form2request
function that returns aRequest
dataclass.GET
, in line with the standard and browser behavior. In Scrapy, it isPOST
if non-empty user data is specified.dialog
method raisesNotImplementedError
.FormElement
through parameters (formname
,formnid
,formnumber
,formxpath
,formcss
). I thought the API would be cleaner if instead we expect aFormElement
as input. To compensate, I documented how to get aFormElement
in all the different ways Scrapy supports using XPath. Parsel support has also been added, and the docs cover how to use Scrapy.clickdata
anddont_click
are merged into a singleclick
keyword-only parameter. Similar toform
,click
accepts anHtmlElement
instead of parameters (clickdata
) that resolve to one. It also supportsNone
(default, same as before),False
(equivalent todont_click=True
) andTrue
(likeNone
, but raises aValueError
if there is no button).action
andmethod
with their corresponding,form
-prefixed attributes. I found about the existence of those attributes while reviewing the implementation, and found it trivial to add support._value
,_select_value
) that does not seem necessary anymore with the minimum supported version of lxml.enctype
(orformenctype
in a submit button) ismultipart/form-data
and method isPOST
,NotImplementedError
is raised.enctype
.text/plain
enctype
, since it was trivial, although it should rarely be used in the wild.Let’s discuss these choices, specially naming and the not implementation of form selection and click selection parameters.
To do
formaction
.enctype
to handle scenarios where a different value is set via JavaScript.