1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-26 19:03:53 +00:00

readable xpath with exslt

This commit is contained in:
Νικόλαος-Διγενής Καραγιάννης 2015-11-14 23:24:07 +02:00
parent 4f98be60be
commit ebfdb9bb03

View File

@ -109,12 +109,11 @@ def _get_inputs(form, formdata, dont_click, clickdata, response):
inputs = form.xpath('descendant::textarea' inputs = form.xpath('descendant::textarea'
'|descendant::select' '|descendant::select'
'|descendant::input[not(@type) or @type[' '|descendant::input[not(@type) or @type['
' translate(., "SUBMIT", "submit") != "submit"' ' not(re:test(., "^(?:submit|image|reset)$", "i"))'
' and translate(., "IMAGE", "image") !="image"' ' and (../@checked or'
' and translate(., "RESET", "reset") != "reset"' ' not(re:test(., "^(?:checkbox|radio)$", "i")))]]',
' and (../@checked or (' namespaces={
' translate(., "CHECKBOX", "checkbox") != "checkbox"' "re": "http://exslt.org/regular-expressions"})
' and translate(., "RADIO", "radio") != "radio"))]]')
values = [(k, u'' if v is None else v) values = [(k, u'' if v is None else v)
for k, v in (_value(e) for e in inputs) for k, v in (_value(e) for e in inputs)
if k and k not in formdata] if k and k not in formdata]
@ -160,8 +159,10 @@ def _get_clickable(clickdata, form):
clickables = [ clickables = [
el for el in form.xpath( el for el in form.xpath(
'descendant::*[(self::input or self::button)' 'descendant::*[(self::input or self::button)'
' and translate(@type, "SUBMIT", "submit") = "submit"]' ' and re:test(@type, "^submit$", "i")]'
'|descendant::button[not(@type)]')] '|descendant::button[not(@type)]',
namespaces={"re": "http://exslt.org/regular-expressions"})
]
if not clickables: if not clickables:
return return