From ebfdb9bb03fd876bf519535dd57ec0816e0c3c2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=9D=CE=B9=CE=BA=CF=8C=CE=BB=CE=B1=CE=BF=CF=82-=CE=94?= =?UTF-8?q?=CE=B9=CE=B3=CE=B5=CE=BD=CE=AE=CF=82=20=CE=9A=CE=B1=CF=81=CE=B1?= =?UTF-8?q?=CE=B3=CE=B9=CE=AC=CE=BD=CE=BD=CE=B7=CF=82?= Date: Sat, 14 Nov 2015 23:24:07 +0200 Subject: [PATCH] readable xpath with exslt --- scrapy/http/request/form.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/scrapy/http/request/form.py b/scrapy/http/request/form.py index 948ad05c9..f623a5aa3 100644 --- a/scrapy/http/request/form.py +++ b/scrapy/http/request/form.py @@ -109,12 +109,11 @@ def _get_inputs(form, formdata, dont_click, clickdata, response): inputs = form.xpath('descendant::textarea' '|descendant::select' '|descendant::input[not(@type) or @type[' - ' translate(., "SUBMIT", "submit") != "submit"' - ' and translate(., "IMAGE", "image") !="image"' - ' and translate(., "RESET", "reset") != "reset"' - ' and (../@checked or (' - ' translate(., "CHECKBOX", "checkbox") != "checkbox"' - ' and translate(., "RADIO", "radio") != "radio"))]]') + ' not(re:test(., "^(?:submit|image|reset)$", "i"))' + ' and (../@checked or' + ' not(re:test(., "^(?:checkbox|radio)$", "i")))]]', + namespaces={ + "re": "http://exslt.org/regular-expressions"}) values = [(k, u'' if v is None else v) for k, v in (_value(e) for e in inputs) if k and k not in formdata] @@ -160,8 +159,10 @@ def _get_clickable(clickdata, form): clickables = [ el for el in form.xpath( 'descendant::*[(self::input or self::button)' - ' and translate(@type, "SUBMIT", "submit") = "submit"]' - '|descendant::button[not(@type)]')] + ' and re:test(@type, "^submit$", "i")]' + '|descendant::button[not(@type)]', + namespaces={"re": "http://exslt.org/regular-expressions"}) + ] if not clickables: return